home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / libraries / mui20dev.lha / MUI / Developer / C / Examples / DFView.c < prev    next >
C/C++ Source or Header  |  1994-02-11  |  87KB  |  3,106 lines

  1. /* $Revision Header built automatically *************** (do not edit) ************
  2. **
  3. ** © Copyright by Dirk Federlein
  4. **
  5. ** File             : DFView.c
  6. ** Created on       : Tuesday, 13.07.93 02:33:25
  7. ** Created by       : Dirk Federlein
  8. ** Current revision : V1.12
  9. **
  10. ** Auto: smake
  11. **
  12. **
  13. **
  14. ** Revision V1.12
  15. ** --------------
  16. ** created on Tuesday, 03.08.93 14:48:10  by  Dirk Federlein.   LogMessage :
  17. **   - Reduced stack usage by replacing all char ...[*] with
  18. **     static char ...[*]. 
  19. **     Added a static to  all "big" structures (struct GlobalPrefs etc.)
  20. **     as well.
  21. **     This has been done, because DFView
  22. **     would not work correctly, if it was compiled with the
  23. **     "standard" demo.h that defines a stack of 8192 Byte.
  24. **     (Request: Stefan Stuntz)
  25. **
  26. ** Revision V1.11
  27. ** --------------
  28. ** created on Monday, 02.08.93 23:11:25  by  Dirk Federlein.   LogMessage :
  29. **  -*-  changed on Monday, 02.08.93 23:12:59  by  Dirk Federlein.   LogMessage :
  30. **   - Changed the kind of the labeling of the gauge objects.
  31. **     Use MUIA_Weight instead of MUIA_SetMax, because
  32. **     MUIA_SetMax made it impossible to format the text 
  33. **     rightsided.
  34. **  -*-  created on Monday, 02.08.93 23:11:25  by  Dirk Federlein.   LogMessage :
  35. **   - Changed the ..._lv_up() and ..._lv_down() function to use
  36. **     the new MUIM_List_Exchange method.
  37. **
  38. ** Revision V1.10
  39. ** --------------
  40. ** created on Friday, 30.07.93 00:28:32  by  Dirk Federlein.   LogMessage :
  41. **   - Removed a bug in the listview-down and listview-bottom
  42. **     functions. The caused the listview to "generate" a junk
  43. **     line if you hit "down" and the listview _was_ empty.
  44. **     Some minor changes in the locale files
  45. **
  46. ** Revision V1.9
  47. ** --------------
  48. ** created on Thursday, 29.07.93 03:26:30  by  Dirk Federlein.   LogMessage :
  49. **   - Added complete online help. 
  50. **     For this reason I wrote a manual for DFView using
  51. **     TeXInfo. The manual is supplied as TeX (DVI), AmigaGuide
  52. **     and ASCII file.
  53. **
  54. ** Revision V1.8
  55. ** --------------
  56. ** created on Tuesday, 27.07.93 15:04:09  by  Dirk Federlein.   LogMessage :
  57. **  -*-  changed on Wednesday, 28.07.93 15:52:57  by  Dirk Federlein.   LogMessage :
  58. **   - Added a few options to the global prefs window
  59. **     (user adjustable listview format). Notice that it is NOT
  60. **     possible to reformat the cycle gadget
  61. **     AT ONCE. These changes are shown after restart only!
  62. **  -*-  changed on Tuesday, 27.07.93 15:05:10  by  Dirk Federlein.   LogMessage :
  63. **   - Did many changes to compile DFView under MUI V40A
  64. **  -*-  changed on Tuesday, 27.07.93 15:04:27  by  Dirk Federlein.   LogMessage :
  65. **   - Removed bug: Tried to get a cycle value via getmutex() :-(
  66. **  -*-  created on Tuesday, 27.07.93 15:04:09  by  Dirk Federlein.   LogMessage :
  67. **   - Added global prefs window
  68. **
  69. ** Revision V1.7
  70. ** --------------
  71. ** created on Wednesday, 21.07.93 13:59:10  by  Dirk Federlein.   LogMessage :
  72. **  -*-  changed on Wednesday, 21.07.93 14:01:01  by  Dirk Federlein.   LogMessage :
  73. **   - Removed the SingleTask=True flag. Now you can start DFView
  74. **     multiple times - great eh?
  75. **     (Request: Stefan Stuntz)
  76. **  -*-  created on Wednesday, 21.07.93 13:59:10  by  Dirk Federlein.   LogMessage :
  77. **   - Removed a BUG that caused the program to crash as soon as
  78. **     the user changed 1st the "Process"-Cycle-Gadget(Preferences)
  79. **     and second tried to view some files.
  80. **
  81. ** Revision V1.6
  82. ** --------------
  83. ** created on Tuesday, 20.07.93 17:17:59  by  Dirk Federlein.   LogMessage :
  84. **  -*-  changed on Tuesday, 20.07.93 20:52:15  by  Dirk Federlein.   LogMessage :
  85. **   - Changed the locale strings refering to pictures to files.
  86. **     DFView doesn't show only pictures, but anything else as
  87. **     well as long as you have a "viewer" for it.
  88. **  -*-  changed on Tuesday, 20.07.93 20:51:09  by  Dirk Federlein.   LogMessage :
  89. **   - Added support for doubleclicking the listview. If you
  90. **     doubleclick an item now it will be shown at once,
  91. **     no matter if it is selected or not.
  92. **     (Request: Stefan Stuntz)
  93. **  -*-  changed on Tuesday, 20.07.93 20:50:16  by  Dirk Federlein.   LogMessage :
  94. **   - Renamed the file from dfv to dfview according to the
  95. **     application name
  96. **     (Request: Stefan Stuntz)
  97. **  -*-  changed on Tuesday, 20.07.93 17:19:09  by  Dirk Federlein.   LogMessage :
  98. **   - Implemented repeat "feature" for <UP> and <DOWN> buttons
  99. **  -*-  created on Tuesday, 20.07.93 17:17:59  by  Dirk Federlein.   LogMessage :
  100. **   - Implemented a better program/pathname determination
  101. **
  102. ** Revision V1.5
  103. ** --------------
  104. ** created on Monday, 19.07.93 02:46:58  by  Dirk Federlein.   LogMessage :
  105. **   - Added Locale support
  106. **
  107. ** Revision V1.4
  108. ** --------------
  109. ** created on Monday, 19.07.93 02:44:40  by  Dirk Federlein.   LogMessage :
  110. **   - Added support for a nicer AppIcon to get rid of the
  111. **     DEFAULT AppIcon.
  112. **     Changed MX gadget to Cycle gadget.
  113. **
  114. ** Revision V1.3
  115. ** --------------
  116. ** created on Sunday, 18.07.93 23:54:47  by  Dirk Federlein.   LogMessage :
  117. **   - Did some changes according to Stefans wishes
  118. **     (No C++ comments, smaller main window)
  119. **
  120. ** Revision V1.2
  121. ** --------------
  122. ** created on Sunday, 18.07.93 13:24:05  by  Dirk Federlein.   LogMessage :
  123. **   - Adaped source according to the changes that came with
  124. **     Version 37A of MUI.
  125. **
  126. ** Revision V1.1
  127. ** --------------
  128. ** created on Saturday, 17.07.93 01:29:51  by  Dirk Federlein.   LogMessage :
  129. **   - Used a MX gadget instead of a Cycle gadget, because of some
  130. **     bugs within the cycle gadget class (35A)
  131. **
  132. **
  133. ** Purpose
  134. ** -------
  135. **   - DFV - The MUI based picture viewer
  136. **
  137. ** Revision V1.0
  138. ** --------------
  139. ** created on Tuesday, 13.07.93 02:33:25  by  Dirk Federlein.   LogMessage :
  140. **     --- Initial release ---
  141. **
  142. *********************************************************************************/
  143. #define REVISION "1.12"
  144. #define REVDATE  "03.08.93"
  145. #define REVTIME  "14:48:10"
  146. #define AUTHOR   "Dirk Federlein"
  147. #define VERNUM   1
  148. #define REVNUM   12
  149.  
  150. /* --- Includes --------------------------------------------------------- */
  151.  
  152. #include "demo.h"
  153.  
  154. #include <libraries/asl.h>
  155.  
  156. #define MAXNAMELEN        256
  157. #define MAXCLILEN        480
  158. #define CMDBUFFER        (MAXCLILEN*2)    /* Just for savety! */
  159.  
  160. #include <exec/memory.h>
  161. #include <workbench/workbench.h>
  162. #include <clib/icon_protos.h>
  163. #include <clib/utility_protos.h>
  164. #include <dos/dos.h>
  165. #include <dos/dostags.h>
  166. #include <libraries/locale.h>
  167. #include <clib/locale_protos.h>
  168.  
  169. #include "dfview_protos.h"
  170.  
  171. #define CATCOMP_NUMBERS
  172. #define CATCOMP_BLOCK
  173.  
  174. #include "dfview_locale.h"
  175.  
  176. /* ---------------------------------------------------------------------- */
  177. /* --- FileList formats ------------------------------------------------- */
  178. /* ---------------------------------------------------------------------- */
  179.  
  180. /* --- Filename only ---------------------------------------------------- */
  181. #define FILELIST_FMT1    "COL=1 DELTA=8"
  182.  
  183. /* --- Filepath and filename -------------------------------------------- */
  184. #define FILELIST_FMT2    "COL=0 DELTA=8,COL=1 DELTA=8"
  185.  
  186. /* --- Filename and filesize -------------------------------------------- */
  187. #define FILELIST_FMT3    "COL=1 DELTA=8,COL=2 DELTA=8 P=\33r"
  188.  
  189. /* --- Filepath, filename and filesize ---------------------------------- */
  190. #define FILELIST_FMT4    "COL=0 DELTA=8,COL=1 DELTA=8,COL=2 DELTA=8 P=\33r"
  191.  
  192. /* ---------------------------------------------------------------------- */
  193. /* --- Online Help File ------------------------------------------------- */
  194. /* ---------------------------------------------------------------------- */
  195.  
  196. #define GUIDEFILE            "DFView.guide"
  197.  
  198. /* ---------------------------------------------------------------------- */
  199. /* --- Online Help Nodes ------------------------------------------------ */
  200. /* ---------------------------------------------------------------------- */
  201.  
  202. #define NODE_MAIN_TOP            "MainWindow"
  203. #define NODE_MAIN_FILES            "Files"
  204. #define NODE_MAIN_FILELIST        "File list"
  205. #define NODE_MAIN_QUICKCHANGE    "Quick change"
  206. #define NODE_MAIN_SELECTED        "Selected"
  207. #define NODE_MAIN_UNSELECTED    "Unselected"
  208. #define NODE_MAIN_PROCESSQUIT    "Process and Quit"
  209.  
  210. #define NODE_PREFS_TOP            "FilePrefs"
  211. #define NODE_PREFS_COMMAND        "Command"
  212. #define NODE_PREFS_PARAMS        "Parameter"
  213. #define NODE_PREFS_PARAMSFIRST    "Params first"
  214. #define NODE_PREFS_AUTODESELECT    "Auto deselect"
  215. #define NODE_PREFS_PROCESS        "ProcessKind"
  216. #define NODE_PREFS_OKCANCEL        "Ok and Cancel"
  217.  
  218. #define NODE_GPREFS_TOP            "DFView Preferences"
  219. #define NODE_GPREFS_FILELISTS    "File lists"
  220. #define NODE_GPREFS_AUTOLOAD    "Auto load"
  221. #define NODE_GPREFS_CLEAR        "ClearALoad"
  222. #define NODE_GPREFS_SHOWPATH    "Show path"
  223. #define NODE_GPREFS_SHOWSIZE    "Show size"
  224.  
  225. /* ---------------------------------------------------------------------- */
  226. /* --- Support Functions ------------------------------------------------ */
  227. /* ---------------------------------------------------------------------- */
  228.  
  229. char *GetStr(APTR obj)
  230. {
  231.     char *str;
  232.  
  233.     if (!get(obj,MUIA_String_Contents,&str))
  234.         get(obj,MUIA_Text_Contents,&str);
  235.  
  236.     return(str);
  237. }
  238.  
  239. BOOL GetBool(APTR obj)
  240. {
  241.     LONG x;
  242.     get(obj,MUIA_Selected,&x);
  243.     return((BOOL)x);
  244. }
  245.  
  246. LONG GetRadio(APTR obj)
  247. {
  248.     LONG x;
  249.     get(obj,MUIA_Radio_Active,&x);
  250.     return((LONG)x);
  251. }
  252.  
  253. LONG GetCycle(APTR obj)
  254. {
  255.     LONG x;
  256.     get(obj,MUIA_Cycle_Active,&x);
  257.     return((LONG)x);
  258. }
  259.  
  260. /* ---------------------------------------------------------------------- */
  261. /* --- Ids -------------------------------------------------------------- */
  262. /* ---------------------------------------------------------------------- */
  263.  
  264. static enum ids
  265. {
  266.     ID_DUMMY,
  267.     ID_MAIN_PICS,
  268.     ID_MAIN_PICVIEW,
  269.     ID_MAIN_ABOUT,
  270.     ID_MAIN_PREFS,
  271.     ID_MAIN_ADD,
  272.     ID_MAIN_REMOVE,
  273.     ID_MAIN_REMSEL,
  274.     ID_MAIN_SELALL,
  275.     ID_MAIN_SELSHIFT,
  276.     ID_MAIN_SELPAT,
  277.     ID_MAIN_SELNONE,
  278.     ID_MAIN_SORT,
  279.     ID_MAIN_TOP,
  280.     ID_MAIN_UP,
  281.     ID_MAIN_DOWN,
  282.     ID_MAIN_BOTTOM,
  283.     ID_MAIN_CLEAR,
  284.     ID_MAIN_SAVE,
  285.     ID_MAIN_LOAD,
  286.     ID_MAIN_FILEPREFS,
  287.     ID_MAIN_QUICK,
  288.     ID_MAIN_SELECTED,
  289.     ID_MAIN_UNSELECTED,
  290.     ID_MAIN_SHOW,
  291.     ID_MAIN_QUIT,
  292.     /* --- Global Preferences ------------------------------------------- */
  293.     ID_GLOBALPREFS_FILES,
  294.     ID_GLOBALPREFS_ADD,
  295.     ID_GLOBALPREFS_REMOVE,
  296.     ID_GLOBALPREFS_REMSEL,
  297.     ID_GLOBALPREFS_SORT,
  298.     ID_GLOBALPREFS_TOP,
  299.     ID_GLOBALPREFS_UP,
  300.     ID_GLOBALPREFS_DOWN,
  301.     ID_GLOBALPREFS_BOTTOM,
  302.     ID_GLOBALPREFS_AUTOLOAD,
  303.     ID_GLOBALPREFS_CLEAR,
  304.     ID_GLOBALPREFS_SHOWPATH,
  305.     ID_GLOBALPREFS_SHOWSIZE,
  306.     ID_GLOBALPREFS_SAVE,
  307.     ID_GLOBALPREFS_LOAD,
  308.     ID_GLOBALPREFS_USE,
  309.     ID_GLOBALPREFS_CANCEL,
  310.     /* --- String requester --------------------------------------------- */
  311.     ID_SREQ_STRING,
  312.     ID_SREQ_OK,
  313.     ID_SREQ_CANCEL,
  314.     /* --- Prefs Window ------------------------------------------------- */
  315.     ID_FILEPREFS_CMD,
  316.     ID_FILEPREFS_GETCMD,
  317.     ID_FILEPREFS_PARAMS,
  318.     ID_FILEPREFS_AUTO,
  319.     ID_FILEPREFS_POS,
  320.     ID_FILEPREFS_KIND,
  321.     ID_FILEPREFS_OK,
  322.     ID_FILEPREFS_CANCEL
  323. };
  324.  
  325. /* ---------------------------------------------------------------------- */
  326. /* --- Handles for the objects ------------------------------------------ */
  327. /* ---------------------------------------------------------------------- */
  328.  
  329. /* --- Application ------------------------------------------------------ */
  330.  
  331. Object * APH_DFV;
  332.  
  333. /* --- Windows ---------------------------------------------------------- */
  334.  
  335. Object * WIH_MAIN;
  336. Object * WIH_SREQ;
  337. Object * WIH_PREFS;
  338. Object * WIH_GLOBALPREFS;
  339.  
  340. /* --- Main Window ------------------------------------------------------ */
  341.  
  342. Object * MAIN_LVH_PICS;
  343. Object * MAIN_LIH_PICS;
  344.  
  345. Object * MAIN_BTH_ADD;
  346. Object * MAIN_BTH_REMOVE;
  347. Object * MAIN_BTH_REMSEL;
  348. Object * MAIN_BTH_SORT;
  349. Object * MAIN_BTH_SELALL;
  350. Object * MAIN_BTH_SELSHIFT;
  351. Object * MAIN_BTH_SELPAT;
  352. Object * MAIN_BTH_SELNONE;
  353. Object * MAIN_BTH_TOP;
  354. Object * MAIN_BTH_UP;
  355. Object * MAIN_BTH_DOWN;
  356. Object * MAIN_BTH_BOTTOM;
  357.  
  358. Object * MAIN_BTH_CLEAR;
  359. Object * MAIN_BTH_SAVE;
  360. Object * MAIN_BTH_LOAD;
  361. Object * MAIN_BTH_PREFS;
  362. Object * MAIN_CYH_QUICK;
  363. Object * MAIN_GAH_SELECTED;
  364. Object * MAIN_GAH_UNSELECTED;
  365.  
  366. Object * MAIN_BTH_SHOW;
  367. Object * MAIN_BTH_QUIT;
  368.  
  369. /* --- Global Preferences ----------------------------------------------- */
  370.  
  371. Object * GLOBALPREFS_LVH_FILES;
  372. Object * GLOBALPREFS_BTH_ADD;
  373. Object * GLOBALPREFS_BTH_REMOVE;
  374. Object * GLOBALPREFS_BTH_REMSEL;
  375. Object * GLOBALPREFS_BTH_SORT;
  376. Object * GLOBALPREFS_BTH_TOP;
  377. Object * GLOBALPREFS_BTH_UP;
  378. Object * GLOBALPREFS_BTH_DOWN;
  379. Object * GLOBALPREFS_BTH_BOTTOM;
  380. Object * GLOBALPREFS_TXH_AUTOLOAD;
  381. Object * GLOBALPREFS_BTH_CLEAR;
  382. Object * GLOBALPREFS_CBH_SHOWPATH;
  383. Object * GLOBALPREFS_CBH_SHOWSIZE;
  384. Object * GLOBALPREFS_BTH_SAVE;
  385. Object * GLOBALPREFS_BTH_LOAD;
  386. Object * GLOBALPREFS_BTH_USE;
  387. Object * GLOBALPREFS_BTH_CANCEL;
  388.  
  389. /* --- String Requester ------------------------------------------------- */
  390.  
  391. Object * SREQ_STH_STRING;
  392. Object * SREQ_BTH_OK;
  393. Object * SREQ_BTH_CANCEL;
  394.  
  395. /* --- File Preferences ------------------------------------------------- */
  396.  
  397. Object * PREFS_STH_CMD;
  398. Object * PREFS_SCH_GETCMD;
  399. Object * PREFS_STH_PARAMS;
  400. Object * PREFS_CBH_POS;
  401. Object * PREFS_CBH_AUTO;
  402. Object * PREFS_CYH_KIND;
  403. Object * PREFS_BTH_OK;
  404. Object * PREFS_BTH_CANCEL;
  405.  
  406. /* ---------------------------------------------------------------------- */
  407. /* --- Cycle gadgets ---------------------------------------------------- */
  408. /* ---------------------------------------------------------------------- */
  409.  
  410. static char * CYA_KIND[] =
  411. {
  412.     "",
  413.     "",
  414.     "",
  415.     NULL,
  416. };
  417.  
  418. static char * CYA_QUICK[22] =
  419. {
  420.     NULL
  421. };
  422.  
  423. /* ---------------------------------------------------------------------- */
  424. /* --- Picture List Entries --------------------------------------------- */
  425. /* ---------------------------------------------------------------------- */
  426.  
  427. struct PicData
  428. {
  429.     char            pd_PicPath[256];    /*    Path only */
  430.     char            pd_PicName[64];        /* Filename only */
  431.     char            pd_PicSize[12];        /* Filesize - not used */
  432.     char            pd_PicRes[32];        /* X x Y x Planes - not used */
  433.     char            pd_PicFormat[16];    /* IFF, PCX, GIF - not used */
  434. };
  435.  
  436. /* ---------------------------------------------------------------------- */
  437. /* --- Picture list preferences ----------------------------------------- */
  438. /* ---------------------------------------------------------------------- */
  439.  
  440. struct PicPrefs
  441. {
  442.     char            pp_Command[256];
  443.     char            pp_Params[256];
  444.     BOOL            pp_Auto;
  445.     BOOL            pp_Pos;
  446.     LONG            pp_Kind;
  447. } PicPrefs =
  448. {
  449.     "", "", TRUE, TRUE, 0L
  450. };
  451.  
  452. /* ---------------------------------------------------------------------- */
  453. /* --- File List Entries ------------------------------------------------ */
  454. /* ---------------------------------------------------------------------- */
  455.  
  456. struct FileData
  457. {
  458.     char            fd_Path[256];
  459.     char            fd_File[64];
  460. };
  461.  
  462. /* ---------------------------------------------------------------------- */
  463. /* --- Global Prefs ----------------------------------------------------- */
  464. /* ---------------------------------------------------------------------- */
  465.  
  466. struct GlobalPrefs
  467. {
  468.     struct FileData        gp_Initial;
  469.  
  470.     struct FileData        gp_QuickChange[20];
  471.  
  472.     BOOL                gp_ShowPath;
  473.     BOOL                gp_ShowSize;
  474. };
  475.  
  476. /* ---------------------------------------------------------------------- */
  477. /* --- Global stuff ----------------------------------------------------- */
  478. /* ---------------------------------------------------------------------- */
  479.  
  480. static char            piclist_dirbuf[256] = { 0,0 };
  481.  
  482. static char            piclist_filebuf[256] = { 0,0 }; /* only 64 used, but... */
  483.  
  484. static char            pic_dirbuf[256] = {0,0};
  485.  
  486. static char            filelist_dirbuf[256] = { 0,0 };
  487.  
  488. struct Library        * WorkbenchBase    = NULL;
  489.  
  490. /* ---------------------------------------------------------------------- */
  491. /* --- Locale stuff ----------------------------------------------------- */
  492. /* ---------------------------------------------------------------------- */
  493.  
  494. struct LocaleInfo        DFVLocaleInfo    = { NULL, NULL };
  495. struct Library            * LocaleBase    = NULL;
  496. APTR                    DFVCatalog        = NULL;
  497.  
  498. STRPTR GetLocaleString( LONG stringNum )
  499. {
  500.     LONG        * l;
  501.     UWORD        * w;
  502.     STRPTR        builtIn;
  503.  
  504.     l = (LONG *)CatCompBlock;
  505.  
  506.     while (*l != stringNum)
  507.     {
  508.         w = (UWORD *)((ULONG)l + 4);
  509.         l = (LONG *)((ULONG)l + (ULONG)*w + 6);
  510.     }
  511.     builtIn = (STRPTR)((ULONG)l + 6);
  512.  
  513.     if (LocaleBase)
  514.         return(GetCatalogStr(DFVCatalog,stringNum,builtIn));
  515.  
  516.     return(builtIn);
  517. }
  518.  
  519. /* ---------------------------------------------------------------------- */
  520. /* --- DiskObject support functions ------------------------------------- */
  521. /* ---------------------------------------------------------------------- */
  522.  
  523. struct DiskObject * dfv_getdiskobject(char * programname)
  524. {
  525.     struct DiskObject        * dobj    = NULL;
  526.  
  527.     if (WorkbenchBase = OpenLibrary("workbench.library", 36))
  528.     {
  529.         dobj = GetDiskObject(programname) ;
  530.  
  531.         CloseLibrary(WorkbenchBase);
  532.     }
  533.  
  534.     return(dobj);
  535. }
  536.  
  537. void dfv_remdiskobject(struct DiskObject * dobj)
  538. {
  539.     if (dobj)
  540.     {
  541.         if (WorkbenchBase = OpenLibrary("workbench.library", 36))
  542.         {
  543.             FreeDiskObject(dobj);
  544.  
  545.             CloseLibrary(WorkbenchBase);
  546.         }
  547.     }
  548. }
  549.  
  550. /* ---------------------------------------------------------------------- */
  551. /* --- Hook functions for the PicData Listview (-> MainWindow) ---------- */
  552. /* ---------------------------------------------------------------------- */
  553.  
  554. SAVEDS ASM APTR ConstructFunc(REG(a0) struct Hook *hook, REG(a2) APTR mempool, REG(a1) struct PicData * pd)
  555. {
  556.     struct PicData *new;
  557.  
  558.     if (new=AllocMem(sizeof(struct PicData),MEMF_ANY))
  559.     {
  560.         *new = *pd;
  561.         return(new);
  562.     }
  563.     return(NULL);
  564. }
  565.  
  566. static struct Hook ConstructHook =
  567. {
  568.     {NULL, NULL},
  569.     (void *)ConstructFunc,
  570.     NULL, NULL
  571. };
  572.  
  573. SAVEDS ASM VOID DestructFunc(REG(a0) struct Hook *hook, REG(a2) APTR mempool, REG(a1) struct PicData * pd)
  574. {
  575.     FreeMem(pd,sizeof(struct PicData));
  576. }
  577.  
  578. static struct Hook DestructHook = {
  579.     {NULL, NULL},
  580.     (void *)DestructFunc,
  581.     NULL, NULL
  582. };
  583.  
  584. SAVEDS ASM LONG CompareFunc(REG(a0) struct Hook *hook, REG(a1) struct PicData * p1,REG(a2) struct PicData * p2)
  585. {
  586.     return(stricmp(p1->pd_PicName,p2->pd_PicName));
  587. }
  588.  
  589. static struct Hook CompareHook = {
  590.     {NULL, NULL},
  591.     (void *)CompareFunc,
  592.     NULL, NULL
  593. };
  594.  
  595. SAVEDS ASM LONG DisplayFunc(REG(a0) struct Hook *hook,REG(a2) char **array,REG(a1) struct PicData *pd)
  596. {
  597.     *array++    = pd->pd_PicPath;
  598.     *array++    = pd->pd_PicName;
  599.  
  600.     /* --- Following fields are not used/filled up to now --------------- */
  601.  
  602.     *array++    = pd->pd_PicSize;
  603.     *array++    = pd->pd_PicRes;
  604.     *array        = pd->pd_PicFormat;
  605.  
  606.     return(0);
  607. }
  608.  
  609. static struct Hook DisplayHook = {
  610.     {NULL, NULL},
  611.     (void *)DisplayFunc,
  612.     NULL, NULL
  613. };
  614.  
  615. /* ---------------------------------------------------------------------- */
  616. /* --- Hooks for the File List (-> Global Prefs) ------------------------ */
  617. /* ---------------------------------------------------------------------- */
  618.  
  619. SAVEDS ASM APTR FileConstructFunc
  620. (
  621.     REG(a0) struct Hook        * hook,
  622.     REG(a2) APTR            mempool,
  623.     REG(a1) struct FileData    * fd
  624. )
  625. {
  626.     struct FileData *new;
  627.  
  628.     if (new=AllocMem(sizeof(struct FileData),MEMF_ANY))
  629.     {
  630.         *new = *fd;
  631.         return(new);
  632.     }
  633.  
  634.     return(NULL);
  635. }
  636.  
  637. static struct Hook FileConstructHook =
  638. {
  639.     {NULL, NULL},
  640.     (void *)FileConstructFunc,
  641.     NULL, NULL
  642. };
  643.  
  644. SAVEDS ASM VOID FileDestructFunc
  645. (
  646.     REG(a0) struct Hook        * hook,
  647.     REG(a2) APTR             mempool,
  648.     REG(a1) struct FileData    * fd
  649. )
  650. {
  651.     FreeMem(fd,sizeof(struct FileData));
  652. }
  653.  
  654. static struct Hook FileDestructHook = {
  655.     {NULL, NULL},
  656.     (void *)FileDestructFunc,
  657.     NULL, NULL
  658. };
  659.  
  660. SAVEDS ASM LONG FileCompareFunc
  661. (
  662.     REG(a0) struct Hook        * hook,
  663.     REG(a1) struct FileData    * f1,
  664.     REG(a2) struct FileData    * f2
  665. )
  666. {
  667.     return(stricmp(f1->fd_File,f2->fd_File));
  668. }
  669.  
  670. static struct Hook FileCompareHook = {
  671.     {NULL, NULL},
  672.     (void *)FileCompareFunc,
  673.     NULL, NULL
  674. };
  675.  
  676. SAVEDS ASM LONG FileDisplayFunc
  677. (
  678.     REG(a0) struct Hook        * hook,
  679.     REG(a2) char            ** array,
  680.     REG(a1) struct FileData    * fd
  681. )
  682. {
  683.     *array++    = fd->fd_Path;
  684.     *array        = fd->fd_File;
  685.  
  686.     return(0);
  687. }
  688.  
  689. static struct Hook FileDisplayHook = {
  690.     {NULL, NULL},
  691.     (void *)FileDisplayFunc,
  692.     NULL, NULL
  693. };
  694.  
  695. /* ---------------------------------------------------------------------- */
  696.  
  697. LONG dfv_load_piclist(char * filename)
  698. {
  699.     char                    * rbuf;
  700.     static char                piclist[256];
  701.     static char                linebuf[256];
  702.  
  703.     LONG                    err        = 0L;
  704.  
  705.     FILE                    * fh    = NULL;
  706.  
  707.     struct FileRequester    * frq;
  708.  
  709.     static struct PicData            pd;
  710.     struct PicData            * pdp;
  711.  
  712.     struct TagItem frqtags[] =
  713.     {
  714.         ASL_Hail,        0L,
  715.         ASL_OKText,        0L,
  716.         ASL_CancelText, 0L,
  717.         ASL_File,        0L,
  718.         ASL_Dir,        0L,
  719.         ASLFR_Window,    0L,
  720.         TAG_DONE
  721.     };
  722.  
  723.     frqtags[0].ti_Data    = (long)GetLocaleString(MSG_LOADPICLIST_WINDOWTITLE);
  724.     frqtags[1].ti_Data    = (long)GetLocaleString(MSG_LOADPICLIST_LOAD);
  725.     frqtags[2].ti_Data    = (long)GetLocaleString(MSG_LOADPICLIST_CANCEL);
  726.     frqtags[3].ti_Data    = (long)piclist_filebuf;
  727.     frqtags[4].ti_Data    = (long)piclist_dirbuf;
  728.  
  729.     if (filename != NULL)
  730.     {
  731.         /* --- Hold listview quiet until all entries are loaded --------- */
  732.  
  733.         set(MAIN_LVH_PICS, MUIA_List_Quiet, TRUE);
  734.  
  735.         if (fh = fopen (filename, "r"))
  736.         {
  737.             fgets(linebuf, 256, fh);
  738.             stccpy(PicPrefs.pp_Command, linebuf, strlen(linebuf));
  739.  
  740.             fgets(linebuf, 256, fh);
  741.             stccpy(PicPrefs.pp_Params, linebuf, strlen(linebuf));
  742.  
  743.             fgets(linebuf, 256, fh);
  744.             PicPrefs.pp_Kind    = atoi(linebuf);
  745.             fgets(linebuf, 256, fh);
  746.             PicPrefs.pp_Pos    = atoi(linebuf);
  747.             fgets(linebuf, 256, fh);
  748.             PicPrefs.pp_Auto    = atoi(linebuf);
  749.  
  750.             do
  751.             {
  752.                 fgets(linebuf, 256, fh);
  753.                 stccpy(pd.pd_PicPath, linebuf, strlen(linebuf));
  754.  
  755.                 fgets(linebuf, 64, fh);
  756.                 stccpy(pd.pd_PicName, linebuf, strlen(linebuf));
  757.  
  758.                 fgets(linebuf, 12, fh);
  759.                 stccpy(pd.pd_PicSize, linebuf, strlen(linebuf));
  760.  
  761.                 fgets(linebuf, 32, fh);
  762.                 stccpy(pd.pd_PicRes, linebuf, strlen(linebuf));
  763.  
  764.                 rbuf = fgets(linebuf, 16, fh);
  765.  
  766.                 stccpy(pd.pd_PicFormat, linebuf, strlen(linebuf));
  767.  
  768.                 if (rbuf)
  769.                 {
  770.                     pdp = &pd;
  771.  
  772.                     DoMethod(MAIN_LVH_PICS,
  773.                         MUIM_List_Insert, &pdp,1, MUIV_List_Insert_Bottom);
  774.                 }
  775.  
  776.             } while(rbuf);
  777.  
  778.             fclose(fh);
  779.  
  780.             dfv_adjust_gauges();
  781.         }
  782.         else
  783.             err = 1L;
  784.  
  785.         /* --- "Wake up" listview --------------------------------------- */
  786.  
  787.         set(MAIN_LVH_PICS, MUIA_List_Quiet, FALSE);
  788.  
  789.     }
  790.     else
  791.     {
  792.         if (frq = (struct FileRequester *)
  793.             MUI_AllocAslRequest(ASL_FileRequest, frqtags))
  794.         {
  795.             if (MUI_AslRequest(frq,NULL))
  796.             {
  797.                 /* --- Save directory --------------------------------------- */
  798.                 stccpy(piclist_dirbuf, frq->fr_Drawer, 256);
  799.  
  800.                 /* --- Save filename ---------------------------------------- */
  801.                 stccpy(piclist_filebuf, frq->fr_File, 64);
  802.  
  803.                 stccpy(piclist, frq->fr_Drawer, 256);
  804.                 AddPart(piclist, frq->fr_File, 256);
  805.  
  806.                 /* --- Hold listview quiet until all entries ---------------- */
  807.                 /* --- are loaded ------------------------------------------- */
  808.  
  809.                 set(MAIN_LVH_PICS, MUIA_List_Quiet, TRUE);
  810.  
  811.                 if (fh = fopen (piclist, "r"))
  812.                 {
  813.                     fgets(linebuf, 256, fh);
  814.                     stccpy(PicPrefs.pp_Command, linebuf, strlen(linebuf));
  815.  
  816.                     fgets(linebuf, 256, fh);
  817.                     stccpy(PicPrefs.pp_Params, linebuf, strlen(linebuf));
  818.  
  819.                     fgets(linebuf, 256, fh);
  820.                     PicPrefs.pp_Kind    = atoi(linebuf);
  821.                     fgets(linebuf, 256, fh);
  822.                     PicPrefs.pp_Pos    = atoi(linebuf);
  823.                     fgets(linebuf, 256, fh);
  824.                     PicPrefs.pp_Auto    = atoi(linebuf);
  825.  
  826.                     do
  827.                     {
  828.                         fgets(linebuf, 256, fh);
  829.                         stccpy(pd.pd_PicPath, linebuf, strlen(linebuf));
  830.  
  831.                         fgets(linebuf, 64, fh);
  832.                         stccpy(pd.pd_PicName, linebuf, strlen(linebuf));
  833.  
  834.                         fgets(linebuf, 12, fh);
  835.                         stccpy(pd.pd_PicSize, linebuf, strlen(linebuf));
  836.  
  837.                         fgets(linebuf, 32, fh);
  838.                         stccpy(pd.pd_PicRes, linebuf, strlen(linebuf));
  839.  
  840.                         rbuf = fgets(linebuf, 16, fh);
  841.  
  842.                         stccpy(pd.pd_PicFormat, linebuf, strlen(linebuf));
  843.  
  844.                         if (rbuf)
  845.                         {
  846.                             pdp = &pd;
  847.                             DoMethod(MAIN_LVH_PICS,
  848.                                 MUIM_List_Insert, &pdp,1, MUIV_List_Insert_Bottom);
  849.                         }
  850.  
  851.                     } while(rbuf);
  852.  
  853.                     fclose(fh);
  854.  
  855.                     dfv_adjust_gauges();
  856.  
  857.                 }
  858.  
  859.                 /* --- "Wake up" listview ------------------------------- */
  860.  
  861.                 set(MAIN_LVH_PICS, MUIA_List_Quiet, FALSE);
  862.  
  863.             }
  864.             else
  865.                 err = 1L;
  866.  
  867.             MUI_FreeAslRequest(frq);
  868.  
  869.         }
  870.     }
  871.  
  872.     return(0L);
  873. }
  874.  
  875. void dfv_clear_piclist(void)
  876. {
  877.     DoMethod(MAIN_LVH_PICS, MUIM_List_Clear);
  878.  
  879.     dfv_adjust_gauges();
  880. }
  881.  
  882. LONG dfv_save_piclist(void)
  883. {
  884.     static char                piclist[256];
  885.     LONG                    err        = 0L;
  886.  
  887.     LONG                    end, i;
  888.  
  889.     FILE                    * fh    = NULL;
  890.  
  891.     struct FileRequester    * frq;
  892.  
  893.     struct PicData            * pdp;
  894.  
  895.     struct TagItem frqtags[] =
  896.     {
  897.         ASL_Hail,        0L,
  898.         ASL_OKText,        0L,
  899.         ASL_CancelText, 0L,
  900.         ASL_File,        0L,
  901.         ASL_Dir,        0L,
  902.         ASLFR_Window,    0L,
  903.         TAG_DONE
  904.     };
  905.  
  906.     frqtags[0].ti_Data    = (long)GetLocaleString(MSG_SAVEPICLIST_WINDOWTITLE);
  907.     frqtags[1].ti_Data    = (long)GetLocaleString(MSG_SAVEPICLIST_SAVE);
  908.     frqtags[2].ti_Data    = (long)GetLocaleString(MSG_SAVEPICLIST_CANCEL);
  909.     frqtags[3].ti_Data    = (long)piclist_filebuf;
  910.     frqtags[4].ti_Data    = (long)piclist_dirbuf;
  911.  
  912.     if (frq = (struct FileRequester *)
  913.         MUI_AllocAslRequest(ASL_FileRequest, frqtags))
  914.     {
  915.         if (MUI_AslRequest(frq,NULL))
  916.         {
  917.             /* --- Save drawer and filename ----------------------------- */
  918.             stccpy(piclist_dirbuf, frq->fr_Drawer, 256);
  919.             stccpy(piclist_filebuf, frq->fr_File, 64);
  920.  
  921.             stccpy(piclist, frq->fr_Drawer, 256);
  922.             AddPart(piclist, frq->fr_File, 256);
  923.  
  924.             if (fh = fopen (piclist, "w"))
  925.             {
  926.                 fprintf(fh,"%s\n", PicPrefs.pp_Command);
  927.                 fprintf(fh,"%s\n", PicPrefs.pp_Params);
  928.                 fprintf(fh,"%ld\n", PicPrefs.pp_Kind);
  929.                 fprintf(fh,"%ld\n", PicPrefs.pp_Pos);
  930.                 fprintf(fh,"%ld\n", PicPrefs.pp_Auto);
  931.  
  932.                 /* --- Get number of all entries ------------------------ */
  933.                 get(MAIN_LVH_PICS, MUIA_List_Entries, &end);
  934.  
  935.                 for (i=0; i<end ; i++)
  936.                 {
  937.                     DoMethod(MAIN_LVH_PICS, MUIM_List_GetEntry, i, &pdp);
  938.  
  939.                     fprintf(fh,"%s\n", pdp->pd_PicPath);
  940.                     fprintf(fh,"%s\n", pdp->pd_PicName);
  941.                     fprintf(fh,"%s\n", pdp->pd_PicSize);
  942.                     fprintf(fh,"%s\n", pdp->pd_PicRes);
  943.                     fprintf(fh,"%s\n", pdp->pd_PicFormat);
  944.                 }
  945.  
  946.                 fclose(fh);
  947.             }
  948.         }
  949.         else
  950.             err = 1L;
  951.  
  952.         MUI_FreeAslRequest(frq);
  953.  
  954.     }
  955.  
  956.     return(0L);
  957. }
  958.  
  959. LONG dfv_add_picture(void)
  960. {
  961.     long err        = 0L;
  962.  
  963.     struct FileRequester    * frq;
  964.  
  965.     struct TagItem frqtags[] =
  966.     {
  967.         ASL_Hail,        0L,
  968.         ASL_OKText,        0L,
  969.         ASL_CancelText, 0L,
  970.         ASL_File,        0L,
  971.         ASL_Dir,        0L,
  972.         ASL_FuncFlags,    FILF_MULTISELECT,    /* Allow multiselect! */
  973.         TAG_DONE, 0L
  974.     };
  975.  
  976.     static struct PicData    npd;
  977.     struct PicData            * npd_ptr = NULL;
  978.  
  979.     frqtags[0].ti_Data    = (long)GetLocaleString(MSG_ADDPIC_WINDOWTITLE);
  980.     frqtags[1].ti_Data    = (long)GetLocaleString(MSG_ADDPIC_SELECT);
  981.     frqtags[2].ti_Data    = (long)GetLocaleString(MSG_ADDPIC_CANCEL);
  982.     frqtags[3].ti_Data    = (long)"";
  983.     frqtags[4].ti_Data    = (long)pic_dirbuf ;
  984.  
  985.     if (frq = (struct FileRequester *)
  986.         MUI_AllocAslRequest(ASL_FileRequest, frqtags))
  987.     {
  988.  
  989.         if (MUI_AslRequest(frq,NULL))
  990.         {
  991.             set(MAIN_LVH_PICS, MUIA_List_Quiet, TRUE);
  992.  
  993.             if (frq->fr_NumArgs)
  994.             {
  995.                 /* Multiselection detected */
  996.  
  997.                 long        x;
  998.  
  999.                 for (x=0; x < frq->fr_NumArgs; x++)
  1000.                 {
  1001.  
  1002.                     stccpy(npd.pd_PicPath, frq->fr_Drawer, 256);
  1003.                     stccpy(npd.pd_PicName, frq->fr_ArgList[x].wa_Name, 64);
  1004.  
  1005.                     /* -------------------------------------------------- */
  1006.                     /* --- Notice: The three items below SHOULD be ------ */
  1007.                     /* --- filled with some USEFULL values, but --------- */
  1008.                     /* --- up to now, I've been too lazy to implement --- */
  1009.                     /* --- this :-) ------------------------------------- */
  1010.  
  1011.                     npd.pd_PicSize[0] = 0;
  1012.                     npd.pd_PicRes[0] = 0;
  1013.                     npd.pd_PicFormat[0] = 0;
  1014.  
  1015.                     /* -------------------------------------------------- */
  1016.  
  1017.                     npd_ptr    = &npd;
  1018.  
  1019.                     DoMethod(MAIN_LVH_PICS,MUIM_List_Insert,&npd_ptr,1,MUIV_List_Insert_Bottom);
  1020.  
  1021.                     set(MAIN_LVH_PICS,MUIA_List_Active,MUIV_List_Active_Bottom);
  1022.  
  1023.                 }
  1024.  
  1025.                 stccpy(pic_dirbuf, frq->fr_Drawer, 256);
  1026.  
  1027.             }
  1028.             else
  1029.             {
  1030.                 /* --- "Normal" selection ------------------------------- */
  1031.  
  1032.                 stccpy(pic_dirbuf, frq->fr_Drawer, 256);
  1033.  
  1034.                 stccpy(npd.pd_PicPath, frq->fr_Drawer, 256);
  1035.                 stccpy(npd.pd_PicName, frq->fr_File, 64);
  1036.  
  1037.                 npd.pd_PicSize[0] = 0;
  1038.                 npd.pd_PicRes[0] = 0;
  1039.                 npd.pd_PicFormat[0] = 0;
  1040.  
  1041.                 npd_ptr    = &npd;
  1042.  
  1043.                 DoMethod(MAIN_LVH_PICS,MUIM_List_Insert,&npd_ptr,1,MUIV_List_Insert_Bottom);
  1044.  
  1045.                 set(MAIN_LVH_PICS,MUIA_List_Active,MUIV_List_Active_Bottom);
  1046.             }
  1047.  
  1048.             set(MAIN_LVH_PICS, MUIA_List_Quiet, FALSE);
  1049.  
  1050.             dfv_adjust_gauges();
  1051.         }
  1052.         else
  1053.             err = 1L;
  1054.  
  1055.         MUI_FreeAslRequest(frq);
  1056.  
  1057.     }
  1058.  
  1059.     return(0L);
  1060. }
  1061.  
  1062. void dfv_rem_picture(void)
  1063. {
  1064.     DoMethod(MAIN_LVH_PICS, MUIM_List_Remove, MUIV_List_Remove_Active );
  1065.  
  1066.     dfv_adjust_gauges();
  1067. }
  1068.  
  1069. void dfv_remsel_picture(void)
  1070. {
  1071.     LONG end, i;
  1072.     LONG sel;
  1073.  
  1074.     /* --- Get number of all entries ------------------------------------ */
  1075.     get(MAIN_LVH_PICS, MUIA_List_Entries, &end);
  1076.  
  1077.     for (i=end-1; i>=0 ; i--)
  1078.     {
  1079.         DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Ask, &sel);
  1080.  
  1081.         if (sel)
  1082.             DoMethod(MAIN_LVH_PICS, MUIM_List_Remove, i );
  1083.     }
  1084.  
  1085.     dfv_adjust_gauges();
  1086. }
  1087.  
  1088. void dfv_lv_top(Object * lv, long size)
  1089. {
  1090.     LONG        pos;
  1091.  
  1092.     char        * data;
  1093.     char        * tmp;
  1094.  
  1095.     if(data = AllocVec(size, MEMF_ANY|MEMF_CLEAR))
  1096.     {
  1097.         get(lv, MUIA_List_Active, &pos);
  1098.  
  1099.         if (pos > 0L)
  1100.         {
  1101.             DoMethod(lv, MUIM_List_GetEntry, pos, &tmp);
  1102.  
  1103.             /* --- Save the data ---------------------------------------- */
  1104.  
  1105.             memcpy (data, tmp, size);
  1106.  
  1107.             /* --- Remove entry ----------------------------------------- */
  1108.  
  1109.             DoMethod(lv, MUIM_List_Remove, pos);
  1110.  
  1111.             tmp = data; /* Set pointer */
  1112.  
  1113.             DoMethod(lv, MUIM_List_Insert, &tmp, 1, MUIV_List_Insert_Top);
  1114.  
  1115.             set(lv, MUIA_List_Active, MUIV_List_Active_Top);
  1116.         }
  1117.  
  1118.         FreeVec(data);
  1119.     }
  1120. }
  1121.  
  1122. void dfv_lv_up(Object * lv)
  1123. {
  1124.     LONG        pos;
  1125.  
  1126.     get(lv, MUIA_List_Active, &pos);
  1127.  
  1128.     if (pos > 0L)
  1129.     {
  1130.         /* --- Exchange entry 'pos' with entry 'pos-1' ------------------ */
  1131.         DoMethod(lv, MUIM_List_Exchange, pos, pos-1);
  1132.  
  1133.         /* --- Previous entry becomes the active entry ------------------ */
  1134.         set(lv, MUIA_List_Active, pos-1);
  1135.     }
  1136.  
  1137. }
  1138.  
  1139. void dfv_lv_down(Object * lv)
  1140. {
  1141.     LONG        pos;
  1142.     LONG        last;
  1143.  
  1144.     get(lv, MUIA_List_Entries, &last);
  1145.     get(lv, MUIA_List_Active, &pos);
  1146.  
  1147.     /* --- Recalc. "last". Notice the MUIA_List_Entries ----------------- */
  1148.     /* --- gives you the number of entries! ----------------------------- */
  1149.  
  1150.     last--;
  1151.  
  1152.     if((pos < last) && (last > 0L))
  1153.     {
  1154.         /* --- Exchange entry 'pos' and entry 'pos+1' ------------------- */
  1155.         DoMethod(lv, MUIM_List_Exchange, pos, pos+1);
  1156.  
  1157.         /* --- Next entry becomes the active one ------------------------ */
  1158.         set(lv, MUIA_List_Active, pos+1);
  1159.     }
  1160. }
  1161.  
  1162. void dfv_lv_bottom(Object * lv, long size)
  1163. {
  1164.     LONG        pos;
  1165.     LONG        last;
  1166.  
  1167.     char        * data;
  1168.     char        * tmp;
  1169.  
  1170.     if(data = AllocVec(size, MEMF_ANY|MEMF_CLEAR))
  1171.     {
  1172.         get(lv, MUIA_List_Entries, &last);
  1173.         get(lv, MUIA_List_Active, &pos);
  1174.  
  1175.         /* --- Recalc. "last". Notice the MUIA_List_Entries ------------- */
  1176.         /* --- gives you the number of entries! ------------------------- */
  1177.  
  1178.         last--;
  1179.  
  1180.         if ((pos < last) && (last>0L))
  1181.         {
  1182.             DoMethod(lv, MUIM_List_GetEntry, pos, &tmp);
  1183.  
  1184.             /* --- Save the data -------------------------------------------- */
  1185.  
  1186.             memcpy (data, tmp, size);
  1187.  
  1188.             DoMethod(lv, MUIM_List_Remove, pos); /* remove entry */
  1189.  
  1190.             tmp = data; /* Set pointer */
  1191.  
  1192.             DoMethod(lv, MUIM_List_Insert, &tmp, 1, MUIV_List_Insert_Bottom);
  1193.  
  1194.             set(lv, MUIA_List_Active, MUIV_List_Active_Bottom);
  1195.         }
  1196.  
  1197.         FreeVec(data);
  1198.     }
  1199. }
  1200.  
  1201. void dfv_lv_sort(Object * lv)
  1202. {
  1203.     DoMethod(lv, MUIM_List_Sort);
  1204. }
  1205.  
  1206. void dfv_selall_picture(void)
  1207. {
  1208.     LONG end, i;
  1209.     LONG sel;
  1210.  
  1211.     /* --- Get number of all entries ------------------------------------ */
  1212.     get(MAIN_LVH_PICS, MUIA_List_Entries, &end);
  1213.  
  1214.     for (i=0; i<end ; i++)
  1215.         DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_On, &sel);
  1216.  
  1217.     /*** refresh display ***/
  1218.     DoMethod(MAIN_LVH_PICS, MUIM_List_Redraw, MUIV_List_Redraw_All);
  1219.  
  1220.     dfv_adjust_gauges();
  1221. }
  1222.  
  1223. void dfv_selshift_picture(void)
  1224. {
  1225.     LONG end, i;
  1226.     LONG sel;
  1227.  
  1228.     /* --- Get number of all entries ------------------------------------ */
  1229.     get(MAIN_LVH_PICS, MUIA_List_Entries, &end);
  1230.  
  1231.     for (i=0; i<end ; i++)
  1232.     {
  1233.         DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Ask, &sel);
  1234.  
  1235.         DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i,
  1236.             sel ? MUIV_List_Select_Off : MUIV_List_Select_On, &sel);
  1237.     }
  1238.  
  1239.     /* --- Refresh display ---------------------------------------------- */
  1240.     DoMethod(MAIN_LVH_PICS, MUIM_List_Redraw, MUIV_List_Redraw_All);
  1241.  
  1242.     dfv_adjust_gauges();
  1243. }
  1244.  
  1245. void dfv_selpat_picture(char * pattern)
  1246. {
  1247.     LONG            end, i;
  1248.     LONG            sel;
  1249.  
  1250.     struct PicData    * picdata;
  1251.  
  1252.     char            * pattern_token;
  1253.  
  1254.     /* --- Alloc mem for pattern_name ----------------------------------- */
  1255.     if (pattern_token = AllocVec(256, MEMF_ANY|MEMF_CLEAR))
  1256.     {
  1257.         /* --- Tokenize pattern ----------------------------------------- */
  1258.         ParsePatternNoCase(pattern, pattern_token, 256);
  1259.  
  1260.         /* --- Get number of all entries -------------------------------- */
  1261.         get(MAIN_LVH_PICS, MUIA_List_Entries, &end);
  1262.  
  1263.         for (i=0; i<end ; i++)
  1264.         {
  1265.             DoMethod(MAIN_LVH_PICS, MUIM_List_GetEntry, i, &picdata);
  1266.  
  1267.             /* --- Check if pic_name fits on pattern -------------------- */
  1268.             if (MatchPatternNoCase(pattern_token, picdata->pd_PicName))
  1269.                 DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_On, &sel);
  1270.         }
  1271.  
  1272.         /*** refresh display ***/
  1273.         DoMethod(MAIN_LVH_PICS, MUIM_List_Redraw, MUIV_List_Redraw_All);
  1274.  
  1275.         FreeVec(pattern_token);
  1276.     }
  1277.  
  1278.     dfv_adjust_gauges();
  1279. }
  1280.  
  1281. void dfv_selnone_picture(void)
  1282. {
  1283.     LONG end, i;
  1284.     LONG sel;
  1285.  
  1286.     /*** get number of all entries ***/
  1287.     get(MAIN_LVH_PICS, MUIA_List_Entries, &end);
  1288.  
  1289.     for (i=0; i<end ; i++)
  1290.         DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Off, &sel);
  1291.  
  1292.     /*** refresh display ***/
  1293.     DoMethod(MAIN_LVH_PICS, MUIM_List_Redraw, MUIV_List_Redraw_All);
  1294.  
  1295.     dfv_adjust_gauges();
  1296. }
  1297.  
  1298. void dfv_show_active(void)
  1299. {
  1300.     char            * command;
  1301.     static char        filepath[256];
  1302.  
  1303.     struct PicData    * pdp;
  1304.  
  1305.     if (command = AllocVec (512, MEMF_ANY|MEMF_CLEAR))
  1306.     {
  1307.  
  1308.         DoMethod(MAIN_LVH_PICS, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &pdp);
  1309.  
  1310.         stccpy(filepath, pdp->pd_PicPath, 256);
  1311.         AddPart(filepath,pdp->pd_PicName, 256);
  1312.  
  1313.         if (PicPrefs.pp_Pos)
  1314.             sprintf(command, "%s %s %s",
  1315.                 PicPrefs.pp_Command, PicPrefs.pp_Params, filepath);
  1316.         else
  1317.             sprintf(command, "%s %s %s",
  1318.                 PicPrefs.pp_Command, filepath, PicPrefs.pp_Params);
  1319.  
  1320.         SystemTags ( command, SYS_Input, NULL,
  1321.             SYS_Output, NULL, TAG_DONE);
  1322.  
  1323.         FreeVec(command);
  1324.     }
  1325. }
  1326.  
  1327.  
  1328. void dfv_show_picture(void)
  1329. {
  1330.     BOOL            notdone        = TRUE;
  1331.     BOOL            anyselected = FALSE;
  1332.  
  1333.     static char        filepath[256];
  1334.     char            * command;
  1335.  
  1336.     LONG            end, i;
  1337.     LONG            sel;
  1338.  
  1339.     struct PicData    * pdp;
  1340.  
  1341.     /* --- Get number of all entries ------------------------------------ */
  1342.     get(MAIN_LVH_PICS, MUIA_List_Entries, &end);
  1343.  
  1344.     switch(PicPrefs.pp_Kind)
  1345.     {
  1346.         case 0:        /* One by one */
  1347.             if (command = AllocVec (CMDBUFFER, MEMF_ANY|MEMF_CLEAR))
  1348.             {
  1349.                 for (i=0; i<end ; i++)
  1350.                 {
  1351.                     /* --- Entry selected ? ----------------------------------------- */
  1352.                     DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Ask, &sel);
  1353.  
  1354.                     if (sel)
  1355.                     {
  1356.                         if (PicPrefs.pp_Auto)
  1357.                         {
  1358.                             LONG        dummy;
  1359.  
  1360.                             DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Off, &dummy);
  1361.  
  1362.                             /*** refresh display ***/
  1363.                             DoMethod(MAIN_LVH_PICS, MUIM_List_Redraw, i);
  1364.                         }
  1365.  
  1366.                         DoMethod(MAIN_LVH_PICS, MUIM_List_GetEntry, i, &pdp);
  1367.  
  1368.                         stccpy(filepath, pdp->pd_PicPath, 256);
  1369.                         AddPart(filepath,pdp->pd_PicName, 256);
  1370.  
  1371.                         if (PicPrefs.pp_Pos)
  1372.                             sprintf(command, "%s %s %s",
  1373.                                 PicPrefs.pp_Command, PicPrefs.pp_Params, filepath);
  1374.                         else
  1375.                             sprintf(command, "%s %s %s",
  1376.                                 PicPrefs.pp_Command, filepath, PicPrefs.pp_Params);
  1377.  
  1378.                         SystemTags ( command, SYS_Input, NULL,
  1379.                             SYS_Output, NULL, TAG_DONE);
  1380.                     }
  1381.                 }
  1382.  
  1383.                 FreeVec(command);
  1384.             }
  1385.  
  1386.             break;
  1387.  
  1388.         case 1:        /* All at once */
  1389.  
  1390.             if (command = AllocVec (CMDBUFFER, MEMF_ANY|MEMF_CLEAR))
  1391.             {
  1392.                 if (PicPrefs.pp_Pos)
  1393.                     sprintf(command, "%s %s ",
  1394.                         PicPrefs.pp_Command, PicPrefs.pp_Params);
  1395.                 else
  1396.                     sprintf(command, "%s ",
  1397.                         PicPrefs.pp_Command);
  1398.  
  1399.                 for (i=0; i<end ; i++)
  1400.                 {
  1401.                     /* --- Entry selected ? ----------------------------------------- */
  1402.                     DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Ask, &sel);
  1403.  
  1404.                     if (sel)
  1405.                     {
  1406.                         anyselected = TRUE;
  1407.  
  1408.                         if (PicPrefs.pp_Auto)
  1409.                         {
  1410.                             LONG        dummy;
  1411.  
  1412.                             DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Off, &dummy);
  1413.  
  1414.                             /* --- Refresh display ---------------------- */
  1415.                             DoMethod(MAIN_LVH_PICS, MUIM_List_Redraw, i);
  1416.                         }
  1417.  
  1418.                         DoMethod(MAIN_LVH_PICS, MUIM_List_GetEntry, i, &pdp);
  1419.  
  1420.                         stccpy(filepath, pdp->pd_PicPath, 256);
  1421.                         AddPart(filepath,pdp->pd_PicName, 256);
  1422.  
  1423.                         if (PicPrefs.pp_Pos == TRUE)
  1424.                         {
  1425.                             if (strlen(command)+strlen(filepath)+1 >= MAXCLILEN)
  1426.                                 goto cmdtoolong1;
  1427.                         }
  1428.                         else
  1429.                         {
  1430.                             if (strlen(command)+strlen(filepath)+1+strlen(PicPrefs.pp_Params)
  1431.                                 >= MAXCLILEN)
  1432.                                 goto cmdtoolong1;
  1433.                         }
  1434.  
  1435.                         strcat(command, filepath);
  1436.                         strcat(command, " ");
  1437.                     }
  1438.                 }
  1439.  
  1440. cmdtoolong1:
  1441.  
  1442.                 if (PicPrefs.pp_Pos == FALSE)
  1443.                 {
  1444.                     strcat(command, PicPrefs.pp_Params);
  1445.                 }
  1446.  
  1447.                 if ( anyselected )
  1448.                     SystemTags ( command, SYS_Input, NULL,
  1449.                         SYS_Output, NULL, TAG_DONE);
  1450.  
  1451.                 FreeVec(command);
  1452.             }
  1453.  
  1454.             break;
  1455.  
  1456.         case 2:        /* All until done */
  1457.  
  1458.             if (command = AllocVec (CMDBUFFER, MEMF_ANY|MEMF_CLEAR))
  1459.             {
  1460.                 i = 0;
  1461.  
  1462.                 while(notdone)
  1463.                 {
  1464.                     notdone = FALSE;
  1465.                     anyselected = FALSE;
  1466.  
  1467.                     if (PicPrefs.pp_Pos)
  1468.                         sprintf(command, "%s %s ",
  1469.                             PicPrefs.pp_Command, PicPrefs.pp_Params);
  1470.                     else
  1471.                         sprintf(command, "%s ",
  1472.                             PicPrefs.pp_Command);
  1473.  
  1474.                     for (; i<end ; i++)
  1475.                     {
  1476.                         /* --- Entry selected ? ----------------------------------------- */
  1477.                         DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Ask, &sel);
  1478.  
  1479.                         if (sel)
  1480.                         {
  1481.                             anyselected = TRUE;
  1482.  
  1483.                             if (PicPrefs.pp_Auto)
  1484.                             {
  1485.                                 LONG        dummy;
  1486.  
  1487.                                 DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Off, &dummy);
  1488.  
  1489.                                 /* --- Refresh display ------------------ */
  1490.                                 DoMethod(MAIN_LVH_PICS, MUIM_List_Redraw, i);
  1491.                             }
  1492.  
  1493.                             DoMethod(MAIN_LVH_PICS, MUIM_List_GetEntry, i, &pdp);
  1494.  
  1495.                             stccpy(filepath, pdp->pd_PicPath, 256);
  1496.                             AddPart(filepath,pdp->pd_PicName, 256);
  1497.  
  1498.                             if (PicPrefs.pp_Pos == TRUE)
  1499.                             {
  1500.                                 if (strlen(command)+strlen(filepath)+1
  1501.                                     >= MAXCLILEN)
  1502.                                 {
  1503.                                     notdone = TRUE;
  1504.                                     goto cmdtoolong;
  1505.                                 }
  1506.                             }
  1507.                             else
  1508.                             {
  1509.                                 if (strlen(command)+strlen(filepath)+1+strlen(PicPrefs.pp_Params)
  1510.                                     >= MAXCLILEN)
  1511.                                 {
  1512.                                     notdone = TRUE;
  1513.                                     goto cmdtoolong;
  1514.                                 }
  1515.                             }
  1516.  
  1517.                             strcat(command, filepath);
  1518.                             strcat(command, " ");
  1519.                         }
  1520.                     }
  1521.  
  1522. cmdtoolong:
  1523.  
  1524.                     if (PicPrefs.pp_Pos == FALSE)
  1525.                     {
  1526.                         strcat(command, PicPrefs.pp_Params);
  1527.                     }
  1528.  
  1529.                     if ( anyselected )
  1530.                         SystemTags ( command, SYS_Input, NULL,
  1531.                             SYS_Output, NULL, TAG_DONE);
  1532.                 }
  1533.  
  1534.                 FreeVec(command);
  1535.             }
  1536.  
  1537.             break;
  1538.  
  1539.         default:
  1540.             break;
  1541.     }
  1542.  
  1543.     dfv_adjust_gauges();
  1544. }
  1545.  
  1546. BOOL OpenStringRequester(void)
  1547. {
  1548.     WIH_SREQ = WindowObject,
  1549.         MUIA_Window_ID, MAKE_ID('S','R','E','Q'),
  1550.         MUIA_Window_Title, GetLocaleString(MSG_SREQ_WINDOWTITLE),
  1551.         MUIA_Window_RefWindow, WIH_MAIN,
  1552.         MUIA_Window_Menu, MUIV_Window_Menu_NoMenu,
  1553.         WindowContents, VGroup,
  1554.             Child, VSpace(2),
  1555.             Child, ColGroup(2),
  1556.                 Child, TextObject,
  1557.                     MUIA_Text_Contents, GetLocaleString(MSG_SREQ_INPUTPATTERN_GAD),
  1558.                     MUIA_Text_HiChar, * GetLocaleString(MSG_SREQ_INPUTPATTERN_SC),
  1559.                     MUIA_Weight,  1,
  1560.                     StringFrame, MUIA_FramePhantomHoriz, TRUE, End,
  1561.                 Child, SREQ_STH_STRING = StringObject,
  1562.                     StringFrame, MUIA_Weight, 100,
  1563.                     MUIA_String_MaxLen, 64, End,
  1564.                 End,
  1565.             Child, VSpace(4),
  1566.             Child, HGroup,
  1567.                 MUIA_Group_SameSize, TRUE,
  1568.                 Child, SREQ_BTH_OK = KeyButton(GetLocaleString(MSG_SREQ_OK_GAD), * GetLocaleString(MSG_SREQ_OK_SC)),
  1569.                 Child, HSpace(0),
  1570.                 Child, SREQ_BTH_CANCEL = KeyButton(GetLocaleString(MSG_SREQ_CANCEL_GAD),* GetLocaleString(MSG_SREQ_CANCEL_SC)),
  1571.                 End,
  1572.             End,
  1573.         End;
  1574.  
  1575.  
  1576.     /* --- String request failed ---------------------------------------- */
  1577.     if (!WIH_SREQ)
  1578.         fail(APH_DFV, GetLocaleString(MSG_ERR_SREQFAILED));
  1579.  
  1580.     /* --- Connections & Cycle ------------------------------------------ */
  1581.  
  1582.     DoMethod(WIH_SREQ, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  1583.         APH_DFV, 2, MUIM_Application_ReturnID, ID_SREQ_CANCEL);
  1584.  
  1585.     DoMethod(SREQ_BTH_OK, MUIM_Notify, MUIA_Pressed, FALSE,
  1586.         APH_DFV, 2, MUIM_Application_ReturnID, ID_SREQ_OK);
  1587.     DoMethod(SREQ_BTH_CANCEL, MUIM_Notify, MUIA_Pressed, FALSE,
  1588.         APH_DFV, 2, MUIM_Application_ReturnID, ID_SREQ_CANCEL);
  1589.  
  1590.     /* --- Do the string activation ------------------------------------- */
  1591.     /* --- Note: This HAS to be done via the DoMethod(..,MUIM_Notify, ..) */
  1592.     /* --- stuff. It can't be done via the MUIA_ControlChar tag. -------- */
  1593.  
  1594.     DoMethod(WIH_SREQ, MUIM_Notify,
  1595.         MUIA_Window_InputEvent, GetLocaleString(MSG_SREQ_INPUTPATTERN_SC),
  1596.         WIH_SREQ, 3, MUIM_Set, MUIA_Window_ActiveObject, SREQ_STH_STRING);
  1597.  
  1598.     /* --- Activate ok-button if string is ready ------------------------ */
  1599.     DoMethod(SREQ_STH_STRING,
  1600.         MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1601.         WIH_SREQ, 3,
  1602.         MUIM_Set, MUIA_Window_ActiveObject, SREQ_BTH_OK);
  1603.  
  1604.     DoMethod(WIH_SREQ, MUIM_Window_SetCycleChain,
  1605.         SREQ_STH_STRING,
  1606.         SREQ_BTH_OK,
  1607.         SREQ_BTH_CANCEL,
  1608.         NULL);
  1609.  
  1610.     /* --- Set main window into sleeping state -------------------------- */
  1611.  
  1612.     set(WIH_MAIN, MUIA_Window_Sleep, TRUE);
  1613.  
  1614.     /* --- Add & open window -------------------------------------------- */
  1615.  
  1616.     DoMethod(APH_DFV, OM_ADDMEMBER, WIH_SREQ);
  1617.     set(WIH_SREQ, MUIA_Window_Open, TRUE);
  1618.     set(WIH_SREQ, MUIA_Window_ActiveObject, SREQ_STH_STRING);
  1619.  
  1620.     return(TRUE);
  1621. }
  1622.  
  1623. void CloseStringRequester(void)
  1624. {
  1625.     /* --- Close & remove window ---------------------------------------- */
  1626.  
  1627.     set(WIH_SREQ, MUIA_Window_Open, FALSE);
  1628.     DoMethod(APH_DFV, OM_REMMEMBER, WIH_SREQ);
  1629.  
  1630.     /* --- Now really KILL the subwindow -------------------------------- */
  1631.  
  1632.     MUI_DisposeObject ( WIH_SREQ );
  1633.  
  1634.     /* --- Wake up main window ------------------------------------------ */
  1635.     set(WIH_MAIN, MUIA_Window_Sleep, FALSE);
  1636. }
  1637.  
  1638. LONG dfv_get_command(void)
  1639. {
  1640.     static char                cmdpath[256];
  1641.     long                     err                = 0L;
  1642.  
  1643.     struct FileRequester    * frq;
  1644.  
  1645.     struct TagItem            frqtags[] =
  1646.     {
  1647.         ASL_Hail,        0L,
  1648.         ASL_OKText,        0L,
  1649.         ASL_CancelText, 0L,
  1650.         ASL_File,        0L,
  1651.         ASL_Dir,        0L,
  1652.         ASLFR_Window,    0L,
  1653.         TAG_DONE
  1654.     };
  1655.  
  1656.     frqtags[0].ti_Data    = (long)GetLocaleString(MSG_GETCMD_WINDOWTITLE);
  1657.     frqtags[1].ti_Data    = (long)GetLocaleString(MSG_GETCMD_SELECT_GAD);
  1658.     frqtags[2].ti_Data    = (long)GetLocaleString(MSG_GETCMD_CANCEL_GAD);
  1659.     frqtags[3].ti_Data    = (long)NULL;
  1660.     frqtags[4].ti_Data    = (long)NULL;
  1661.     frqtags[5].ti_Data    = (long)NULL;
  1662.  
  1663.     if (frq = (struct FileRequester *)
  1664.         MUI_AllocAslRequest(ASL_FileRequest, frqtags))
  1665.     {
  1666.         if (MUI_AslRequest(frq,NULL))
  1667.         {
  1668.  
  1669.             stccpy(cmdpath, frq->fr_Drawer, 256);
  1670.             AddPart(cmdpath, frq->fr_File, 256);
  1671.  
  1672.             set(PREFS_STH_CMD, MUIA_String_Contents, cmdpath);
  1673.         }
  1674.         else
  1675.             err = 1L;
  1676.  
  1677.         MUI_FreeAslRequest(frq);
  1678.  
  1679.     }
  1680.  
  1681.     return(0L);
  1682. }
  1683.  
  1684. LONG OpenPrefsWindow(void)
  1685. {
  1686.     CYA_KIND[0]        = GetLocaleString(MSG_FILEPREFS_CY1_GAD);
  1687.     CYA_KIND[1]        = GetLocaleString(MSG_FILEPREFS_CY2_GAD);
  1688.     CYA_KIND[2]        = GetLocaleString(MSG_FILEPREFS_CY3_GAD);
  1689.  
  1690.     WIH_PREFS = WindowObject,
  1691.         MUIA_Window_ID, MAKE_ID('P','R','F','S'),
  1692.         MUIA_HelpNode, NODE_PREFS_TOP,
  1693.         MUIA_Window_Title, GetLocaleString(MSG_FILEPREFS_WINDOWTITLE),
  1694.         MUIA_Window_RefWindow, WIH_MAIN,
  1695.         MUIA_Window_Menu, MUIV_Window_Menu_NoMenu,
  1696.         WindowContents, VGroup,
  1697.             Child, VSpace(2),
  1698.             Child, ColGroup(2),
  1699.                 Child, TextObject,
  1700.                     MUIA_HelpNode, NODE_PREFS_COMMAND,
  1701.                     MUIA_Text_PreParse, "\33r",
  1702.                     MUIA_Text_Contents, GetLocaleString(MSG_FILEPREFS_COMMAND_GAD),
  1703.                     MUIA_Text_HiChar  ,* GetLocaleString(MSG_FILEPREFS_COMMAND_SC),
  1704.                     MUIA_Weight,  1,
  1705.                     StringFrame, MUIA_FramePhantomHoriz, TRUE, End,
  1706.                 Child, HGroup, GroupSpacing(1),
  1707.                     MUIA_HelpNode, NODE_PREFS_COMMAND,
  1708.                     Child, PREFS_STH_CMD = StringObject,
  1709.                         StringFrame, MUIA_Weight, 100,
  1710.                         MUIA_InputMode    , MUIV_InputMode_None,
  1711.                         MUIA_String_MaxLen, 256, End,
  1712.                     Child, PREFS_SCH_GETCMD = ImageObject,
  1713.                         MUIA_Image_Spec, MUII_PopFile,
  1714.                         MUIA_Image_FreeVert, TRUE,
  1715.                         MUIA_ShowSelState     , TRUE,
  1716.                         MUIA_Weight, 1,
  1717.                         MUIA_ControlChar  , ToUpper(* GetLocaleString(MSG_FILEPREFS_COMMAND_SC)),
  1718.                         MUIA_Frame    , MUIV_Frame_Button,
  1719.                         MUIA_Background   , MUII_BACKGROUND,
  1720.                         MUIA_InputMode    , MUIV_InputMode_RelVerify,
  1721.                         End,
  1722.                     End,
  1723.                 Child, TextObject,
  1724.                     MUIA_HelpNode, NODE_PREFS_PARAMS,
  1725.                     MUIA_Text_PreParse, "\33r",
  1726.                     MUIA_Text_Contents, GetLocaleString(MSG_FILEPREFS_PARAMS_GAD),
  1727.                     MUIA_Text_HiChar  ,*  GetLocaleString(MSG_FILEPREFS_PARAMS_SC),
  1728.                     MUIA_Weight,  1,
  1729.                     StringFrame, MUIA_FramePhantomHoriz, TRUE, End,
  1730.                 Child, PREFS_STH_PARAMS = StringObject,
  1731.                     MUIA_HelpNode, NODE_PREFS_PARAMS,
  1732.                     StringFrame, MUIA_Weight, 100,
  1733.                     MUIA_InputMode    , MUIV_InputMode_None,
  1734.                     MUIA_String_MaxLen, 256, End,
  1735.                 End,
  1736.             Child, VSpace(2),
  1737.             Child, HGroup, MUIA_Group_SameSize, TRUE, GroupFrame,
  1738.                 Child, VGroup,
  1739.                     Child, HGroup,
  1740.                         MUIA_HelpNode, NODE_PREFS_PARAMSFIRST,
  1741.                         Child, PREFS_CBH_POS = KeyCheckMark(TRUE,*  GetLocaleString(MSG_FILEPREFS_POS_SC)),
  1742.                         Child, HSpace(1),
  1743.                         Child, TextObject,
  1744.                             MUIA_Text_PreParse, "\33l",
  1745.                             MUIA_Text_Contents, GetLocaleString(MSG_FILEPREFS_POS_GAD),
  1746.                             MUIA_Text_HiChar  ,* GetLocaleString(MSG_FILEPREFS_POS_SC),
  1747.                             MUIA_Weight,  1,
  1748.                             StringFrame, MUIA_FramePhantomHoriz, TRUE, End,
  1749.                     End,
  1750.                     Child, HGroup,
  1751.                         MUIA_HelpNode, NODE_PREFS_AUTODESELECT,
  1752.                         Child, PREFS_CBH_AUTO = KeyCheckMark(TRUE,*  GetLocaleString(MSG_FILEPREFS_AUTO_SC)),
  1753.                         Child, HSpace(1),
  1754.                         Child, TextObject,
  1755.                             MUIA_Text_PreParse, "\33l",
  1756.                             MUIA_Text_Contents, GetLocaleString(MSG_FILEPREFS_AUTO_GAD),
  1757.                             MUIA_Text_HiChar  ,*  GetLocaleString(MSG_FILEPREFS_AUTO_SC),
  1758.                             MUIA_Weight,  1,
  1759.                             StringFrame, MUIA_FramePhantomHoriz, TRUE, End,
  1760.                     End,
  1761.                 End,
  1762.                 Child, ColGroup(2),
  1763.                     MUIA_HelpNode, NODE_PREFS_PROCESS,
  1764.                     Child, TextObject,
  1765.                         MUIA_Text_PreParse, "\33r",
  1766.                         MUIA_Text_Contents, GetLocaleString(MSG_FILEPREFS_PROCESS_GAD),
  1767.                         MUIA_Weight, 0, MUIA_InnerLeft, 0,
  1768.                         MUIA_InnerRight, 0,
  1769.                         MUIA_Text_HiChar,*  GetLocaleString(MSG_FILEPREFS_PROCESS_SC),
  1770.                         TextFrame, MUIA_FramePhantomHoriz, TRUE,
  1771.                     End,
  1772.                     Child, PREFS_CYH_KIND = KeyCycle(CYA_KIND,*  (GetLocaleString(MSG_FILEPREFS_PROCESS_SC))),
  1773.                 End,
  1774.             End,
  1775.  
  1776.             Child, VSpace(4),
  1777.  
  1778.             Child, HGroup,
  1779.                 MUIA_HelpNode, NODE_PREFS_OKCANCEL,
  1780.                 MUIA_Group_SameSize, TRUE,
  1781.                 Child, PREFS_BTH_OK = KeyButton(GetLocaleString(MSG_FILEPREFS_OK_GAD),* GetLocaleString(MSG_FILEPREFS_OK_SC)),
  1782.                 Child, HSpace(0),
  1783.                 Child, HSpace(0),
  1784.                 Child, HSpace(0),
  1785.                 Child, PREFS_BTH_CANCEL = KeyButton(GetLocaleString(MSG_FILEPREFS_CANCEL_GAD),* GetLocaleString(MSG_FILEPREFS_CANCEL_SC)),
  1786.             End,
  1787.         End,
  1788.     End;
  1789.  
  1790.     /* --- Preferences Window OK ? -------------------------------------- */
  1791.     if (!WIH_PREFS)
  1792.         fail(APH_DFV, "Creating prefs window failed !");
  1793.  
  1794.     /* --- Connections -------------------------------------------------- */
  1795.  
  1796.     DoMethod(WIH_PREFS, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  1797.         APH_DFV, 2, MUIM_Application_ReturnID, ID_FILEPREFS_CANCEL);
  1798.  
  1799.     DoMethod(PREFS_SCH_GETCMD, MUIM_Notify, MUIA_Pressed, FALSE,
  1800.         APH_DFV, 2, MUIM_Application_ReturnID, ID_FILEPREFS_GETCMD);
  1801.     DoMethod(PREFS_BTH_OK, MUIM_Notify, MUIA_Pressed, FALSE,
  1802.         APH_DFV, 2, MUIM_Application_ReturnID, ID_FILEPREFS_OK);
  1803.     DoMethod(PREFS_BTH_CANCEL, MUIM_Notify, MUIA_Pressed, FALSE,
  1804.         APH_DFV, 2, MUIM_Application_ReturnID, ID_FILEPREFS_CANCEL);
  1805.  
  1806.     /* --- Do the string activation ------------------------------------- */
  1807.     /* --- Note: This HAS to be done via the DoMethod(..,MUIM_Notify, ..) */
  1808.     /* --- stuff. It can't be done via the MUIA_ControlChar tag. -------- */
  1809.  
  1810.     DoMethod(WIH_PREFS, MUIM_Notify,
  1811.         MUIA_Window_InputEvent, GetLocaleString(MSG_FILEPREFS_COMMAND_SC),
  1812.         WIH_PREFS, 3, MUIM_Set, MUIA_Window_ActiveObject, PREFS_STH_CMD);
  1813.     DoMethod(WIH_PREFS, MUIM_Notify,
  1814.         MUIA_Window_InputEvent, GetLocaleString(MSG_FILEPREFS_PARAMS_SC),
  1815.         WIH_PREFS, 3, MUIM_Set, MUIA_Window_ActiveObject, PREFS_STH_PARAMS);
  1816.  
  1817.     /* --- Cycle chain -------------------------------------------------- */
  1818.  
  1819.     DoMethod(WIH_PREFS, MUIM_Window_SetCycleChain,
  1820.         PREFS_STH_CMD,
  1821.         PREFS_SCH_GETCMD,
  1822.         PREFS_STH_PARAMS,
  1823.         PREFS_CBH_POS,
  1824.         PREFS_CBH_AUTO,
  1825.         PREFS_CYH_KIND,
  1826.         PREFS_BTH_OK,
  1827.         PREFS_BTH_CANCEL,
  1828.         NULL);
  1829.  
  1830.     /* --- Set values --------------------------------------------------- */
  1831.     setstring(PREFS_STH_CMD, PicPrefs.pp_Command);
  1832.     setstring(PREFS_STH_PARAMS, PicPrefs.pp_Params);
  1833.  
  1834.     setcycle(PREFS_CYH_KIND, PicPrefs.pp_Kind);
  1835.     setcheckmark(PREFS_CBH_POS, PicPrefs.pp_Pos);
  1836.     setcheckmark(PREFS_CBH_AUTO, PicPrefs.pp_Auto);
  1837.  
  1838.     /* --- Set main window into sleeping state -------------------------- */
  1839.  
  1840.     set(WIH_MAIN, MUIA_Window_Sleep, TRUE);
  1841.  
  1842.     /* --- Add & open window -------------------------------------------- */
  1843.  
  1844.     DoMethod(APH_DFV, OM_ADDMEMBER, WIH_PREFS);
  1845.     set(WIH_PREFS, MUIA_Window_Open, TRUE);
  1846.  
  1847.     return(TRUE);
  1848. }
  1849.  
  1850. void ClosePrefsWindow(void)
  1851. {
  1852.     /* --- Close & remove window ---------------------------------------- */
  1853.  
  1854.     set(WIH_PREFS, MUIA_Window_Open, FALSE);
  1855.  
  1856.     DoMethod(APH_DFV, OM_REMMEMBER, WIH_PREFS);
  1857.  
  1858.     /* --- Now really KILL the subwindow -------------------------------- */
  1859.  
  1860.     MUI_DisposeObject ( WIH_PREFS );
  1861.  
  1862.     /* --- Wake up main window ------------------------------------------ */
  1863.  
  1864.     set(WIH_MAIN, MUIA_Window_Sleep, FALSE);
  1865. }
  1866.  
  1867. /* ---------------------------------------------------------------------- */
  1868. /* --- Global Prefs support funtions ------------------------------------ */
  1869. /* ---------------------------------------------------------------------- */
  1870.  
  1871. void dfv_readprefs(struct GlobalPrefs * gp)
  1872. {
  1873.     static char        linebuf[256]    = { 0,0 } ;
  1874.  
  1875.     long            i;
  1876.  
  1877.     FILE            * envfile;
  1878.  
  1879.     if (envfile = fopen ("ENV:DFView", "r"))
  1880.     {
  1881.         fgets(linebuf, 256, envfile);
  1882.  
  1883.         stccpy(gp->gp_Initial.fd_Path, linebuf, strlen(linebuf));
  1884.  
  1885.         fgets(linebuf, 256, envfile);
  1886.  
  1887.         stccpy(gp->gp_Initial.fd_File, linebuf, strlen(linebuf));
  1888.  
  1889.         fgets(linebuf, 256, envfile);
  1890.  
  1891.         gp->gp_ShowPath        = atoi (linebuf);
  1892.  
  1893.         fgets(linebuf, 256, envfile);
  1894.  
  1895.         gp->gp_ShowSize        = atoi (linebuf);
  1896.  
  1897.         /* --- Read the filelists --------------------------------------- */
  1898.  
  1899.         i = 0;
  1900.  
  1901.         while (fgets(linebuf, 256, envfile) != NULL)
  1902.         {
  1903.             stccpy(gp->gp_QuickChange[i].fd_Path, linebuf, strlen(linebuf));
  1904.  
  1905.             fgets(linebuf, 256, envfile);
  1906.  
  1907.             stccpy(gp->gp_QuickChange[i].fd_File, linebuf, strlen(linebuf));
  1908.  
  1909.             i++;
  1910.         }
  1911.  
  1912.         fclose(envfile);
  1913.     }
  1914.     else
  1915.     {
  1916.         /* --- Not prefs File - set all to NULL ------------------------- */
  1917.  
  1918.         *(gp->gp_Initial.fd_Path)    = 0;
  1919.         *(gp->gp_Initial.fd_File)    = 0;
  1920.  
  1921.         gp->gp_ShowPath                = FALSE;
  1922.         gp->gp_ShowSize                = FALSE;
  1923.  
  1924.         for(i=0;i<20;i++)
  1925.         {
  1926.             *(gp->gp_QuickChange[i].fd_Path)    = 0;
  1927.             *(gp->gp_QuickChange[i].fd_File)    = 0;
  1928.         }
  1929.     }
  1930. }
  1931.  
  1932. void dfv_saveprefs(struct GlobalPrefs * gp)
  1933. {
  1934.     long            i;
  1935.  
  1936.     FILE            * envfile;
  1937.  
  1938.     /* --- Save Prefs to env: ------------------------------------------- */
  1939.  
  1940.     if (envfile = fopen ("ENV:DFView", "w"))
  1941.     {
  1942.         fprintf(envfile, "%s\n", gp->gp_Initial.fd_Path);
  1943.         fprintf(envfile, "%s\n", gp->gp_Initial.fd_File);
  1944.  
  1945.         fprintf(envfile, "%d\n", gp->gp_ShowPath);
  1946.         fprintf(envfile, "%d\n", gp->gp_ShowSize);
  1947.  
  1948.         for(i=0; i<20; i++)
  1949.         {
  1950.             fprintf(envfile, "%s\n", gp->gp_QuickChange[i].fd_Path);
  1951.             fprintf(envfile, "%s\n", gp->gp_QuickChange[i].fd_File);
  1952.         }
  1953.  
  1954.         fclose(envfile);
  1955.     }
  1956.  
  1957.     /* --- Save Prefs to EnvArc: ---------------------------------------- */
  1958.  
  1959.     if (envfile = fopen ("ENVARC:DFView", "w"))
  1960.     {
  1961.         fprintf(envfile, "%s\n", gp->gp_Initial.fd_Path);
  1962.         fprintf(envfile, "%s\n", gp->gp_Initial.fd_File);
  1963.  
  1964.         fprintf(envfile, "%d\n", gp->gp_ShowPath);
  1965.         fprintf(envfile, "%d\n", gp->gp_ShowSize);
  1966.  
  1967.         for(i=0; i<20; i++)
  1968.         {
  1969.             fprintf(envfile, "%s\n", gp->gp_QuickChange[i].fd_Path);
  1970.             fprintf(envfile, "%s\n", gp->gp_QuickChange[i].fd_File);
  1971.         }
  1972.  
  1973.         fclose(envfile);
  1974.     }
  1975. }
  1976.  
  1977. void dfv_acceptprefs(struct GlobalPrefs * gp)
  1978. {
  1979.     char        * lvformat    = ",";
  1980.  
  1981.     LONG        last;
  1982.     LONG        i;
  1983.  
  1984.     struct FileData        * fdp;
  1985.  
  1986.     /* --- Get Text value ----------------------------------------------- */
  1987.  
  1988.     strcpy (gp->gp_Initial.fd_Path, GetStr(GLOBALPREFS_TXH_AUTOLOAD));
  1989.     strcpy (gp->gp_Initial.fd_File, FilePart(GetStr(GLOBALPREFS_TXH_AUTOLOAD)));
  1990.  
  1991.     /* --- Cut off filename from path ----------------------------------- */
  1992.  
  1993.     gp->gp_Initial.fd_Path[strlen(gp->gp_Initial.fd_Path)-strlen(gp->gp_Initial.fd_File)]
  1994.         = 0;
  1995.  
  1996.     /* --- Get FileListView format CBs ---------------------------------- */
  1997.  
  1998.     gp->gp_ShowPath        = GetBool(GLOBALPREFS_CBH_SHOWPATH);
  1999.     gp->gp_ShowSize        = GetBool(GLOBALPREFS_CBH_SHOWSIZE);
  2000.  
  2001.     /* --- Get number of list entries ----------------------------------- */
  2002.  
  2003.     get(GLOBALPREFS_LVH_FILES, MUIA_List_Entries, &last);
  2004.  
  2005.     if (last)
  2006.     {
  2007.         for(i=0; i<last; i++)
  2008.         {
  2009.             DoMethod(GLOBALPREFS_LVH_FILES, MUIM_List_GetEntry, i, &fdp);
  2010.  
  2011.             strcpy(gp->gp_QuickChange[i].fd_Path, fdp->fd_Path);
  2012.             strcpy(gp->gp_QuickChange[i].fd_File, fdp->fd_File);
  2013.         }
  2014.  
  2015.         if (last<20)
  2016.         {
  2017.             *(gp->gp_QuickChange[last+1].fd_Path) = 0;
  2018.             *(gp->gp_QuickChange[last+1].fd_File) = 0;
  2019.         }
  2020.         else
  2021.         {
  2022.             *(gp->gp_QuickChange[20].fd_Path) = 0;
  2023.             *(gp->gp_QuickChange[20].fd_File) = 0;
  2024.         }
  2025.     }
  2026.     else
  2027.     {
  2028.         /* --- Listview is empty ---------------------------------------- */
  2029.         /* --- Clear all strings ---------------------------------------- */
  2030.         for (i=0;i<20;i++)
  2031.         {
  2032.             *(gp->gp_QuickChange[i].fd_Path)    = 0;
  2033.             *(gp->gp_QuickChange[i].fd_File)    = 0;
  2034.         }
  2035.     }
  2036.  
  2037.     /* ------------------------------------------------------------------ */
  2038.     /* --- Important: You will NOT see your changes at once, ------------ */
  2039.     /* --- but only after you quited your application and restarted it -- */
  2040.     /* --- This is, because it is NOT ALLOWED to change the contents ---- */
  2041.     /* --- of an existing cycle gadget! Sorry. -------------------------- */
  2042.     /* ------------------------------------------------------------------ */
  2043.  
  2044.     /* --- Of course, the Listview will be reformatted at once ---------- */
  2045.  
  2046.     if(gp->gp_ShowPath)
  2047.     {
  2048.         if(gp->gp_ShowSize)
  2049.         {
  2050.             /* --- Filepath, filename and filesize ---------------------- */
  2051.             lvformat    = FILELIST_FMT4;
  2052.         }
  2053.         else
  2054.         {
  2055.             /* --- Filepath and filename -------------------------------- */
  2056.             lvformat    = FILELIST_FMT2;
  2057.         }
  2058.     }
  2059.     else
  2060.     {
  2061.         if(gp->gp_ShowSize)
  2062.         {
  2063.             /* --- Filename and filesize -------------------------------- */
  2064.             lvformat    = FILELIST_FMT3;
  2065.         }
  2066.         else
  2067.         {
  2068.             /* --- Filename only ---------------------------------------- */
  2069.             lvformat    = FILELIST_FMT1;
  2070.         }
  2071.     }
  2072.  
  2073.     set(MAIN_LVH_PICS, MUIA_List_Format, lvformat);
  2074. }
  2075.  
  2076. long dfv_addfileentry(void)
  2077. {
  2078.     char            filepath[256];
  2079.  
  2080.     long             err        = 0L;
  2081.  
  2082.     BPTR            lock;
  2083.  
  2084.     struct FileRequester    * frq;
  2085.  
  2086.     struct TagItem frqtags[] =
  2087.     {
  2088.         ASL_Hail,        0L,
  2089.         ASL_OKText,        0L,
  2090.         ASL_CancelText, 0L,
  2091.         ASL_File,        0L,
  2092.         ASL_Dir,        0L,
  2093.         TAG_DONE, 0L
  2094.     };
  2095.  
  2096.     struct FileData        fd;
  2097.     struct FileData        * fdp;
  2098.  
  2099.     frqtags[0].ti_Data    = (long)GetLocaleString(MSG_ADDFILELIST_WINDOWTITLE);
  2100.     frqtags[1].ti_Data    = (long)GetLocaleString(MSG_ADDFILELIST_LOAD);
  2101.     frqtags[2].ti_Data    = (long)GetLocaleString(MSG_ADDFILELIST_CANCEL);
  2102.     frqtags[3].ti_Data    = (long)"";
  2103.     frqtags[4].ti_Data    = (long)filelist_dirbuf;
  2104.  
  2105.     if (frq = (struct FileRequester *)
  2106.         MUI_AllocAslRequest(ASL_FileRequest, frqtags))
  2107.     {
  2108.  
  2109.         if (MUI_AslRequest(frq,NULL))
  2110.         {
  2111.             stccpy(filelist_dirbuf, frq->fr_Drawer, 256);
  2112.  
  2113.             stccpy(filepath, frq->fr_Drawer, 256);
  2114.  
  2115.             AddPart(filepath, frq->fr_File, 256);
  2116.  
  2117.             if (lock = Lock(filepath, ACCESS_READ))
  2118.             {
  2119.                 NameFromLock(lock, fd.fd_Path, 256);
  2120.  
  2121.                 UnLock(lock);
  2122.  
  2123.                 /* --- Fill in filename --------------------------------- */
  2124.                 stccpy(fd.fd_File, FilePart(fd.fd_Path), 64);
  2125.  
  2126.                 /* --- Cut off filename --------------------------------- */
  2127.  
  2128.                 fd.fd_Path[strlen(fd.fd_Path)-strlen(fd.fd_File)] = 0;
  2129.  
  2130.                 fdp    = &fd;
  2131.  
  2132.                 DoMethod(GLOBALPREFS_LVH_FILES,MUIM_List_Insert,&fdp,1,MUIV_List_Insert_Bottom);
  2133.  
  2134.                 set(GLOBALPREFS_LVH_FILES,MUIM_List_Insert,MUIV_List_Insert_Bottom);
  2135.             }
  2136.             else
  2137.                 err = 1L;
  2138.         }
  2139.         else
  2140.             err = 1L;
  2141.  
  2142.         MUI_FreeAslRequest(frq);
  2143.     }
  2144.  
  2145.     return(0L);
  2146. }
  2147.  
  2148. void dfv_remfileentry(void)
  2149. {
  2150.     DoMethod(GLOBALPREFS_LVH_FILES, MUIM_List_Remove, MUIV_List_Remove_Active );
  2151. }
  2152.  
  2153. void dfv_remselfileentries(void)
  2154. {
  2155.     LONG end, i;
  2156.     LONG sel;
  2157.  
  2158.     /* --- Get number of all entries ------------------------------------ */
  2159.     get(GLOBALPREFS_LVH_FILES, MUIA_List_Entries, &end);
  2160.  
  2161.     for (i=end-1; i>=0 ; i--)
  2162.     {
  2163.         DoMethod(GLOBALPREFS_LVH_FILES, MUIM_List_Select, i, MUIV_List_Select_Ask, &sel);
  2164.  
  2165.         if (sel)
  2166.             DoMethod(GLOBALPREFS_LVH_FILES, MUIM_List_Remove, i );
  2167.     }
  2168. }
  2169.  
  2170. /* ---------------------------------------------------------------------- */
  2171.  
  2172. LONG OpenGlobalPrefs(struct GlobalPrefs * gp)
  2173. {
  2174.     static char    initialstring[256];
  2175.  
  2176.     LONG        i;
  2177.  
  2178.     struct FileData        fd;
  2179.     struct FileData        * fdp;
  2180.  
  2181.     /* --- Generate text for text gadget -------------------------------- */
  2182.  
  2183.     strcpy(initialstring, gp->gp_Initial.fd_Path);
  2184.     AddPart(initialstring, gp->gp_Initial.fd_File, 256);
  2185.  
  2186.     WIH_GLOBALPREFS = WindowObject,
  2187.         MUIA_Window_ID, MAKE_ID('G','L','O','B'),
  2188.         MUIA_HelpNode, NODE_GPREFS_TOP,
  2189.         MUIA_Window_Title, GetLocaleString(MSG_GLOBALPREFS_WINDOWTITLE),
  2190.         MUIA_Window_RefWindow, WIH_MAIN,
  2191.         MUIA_Window_Menu, MUIV_Window_Menu_NoMenu,
  2192.             WindowContents, VGroup,
  2193.                 Child, VGroup,
  2194.                     Child, HGroup, MUIA_Group_SameHeight, TRUE,
  2195.                         Child, VGroup,
  2196.                             Child, VGroup, GroupSpacing(0),
  2197.                                 GroupFrameT(GetLocaleString(MSG_GLOBALPREFS_FILES_GAD)),
  2198.                                 MUIA_HelpNode, NODE_GPREFS_FILELISTS,
  2199.                                 Child, GLOBALPREFS_LVH_FILES = ListviewObject,
  2200.                                     MUIA_Listview_List, ListObject,
  2201.                                         InputListFrame,
  2202.                                         MUIA_List_Format, "COL=0 DELTA=8, COL=1 DELTA=8",
  2203.                                         MUIA_List_ConstructHook, &FileConstructHook,
  2204.                                         MUIA_List_DestructHook, &FileDestructHook,
  2205.                                         MUIA_List_DisplayHook, &FileDisplayHook,
  2206.                                         MUIA_List_CompareHook, &FileCompareHook,
  2207.                                     End,
  2208.                                 End,
  2209.                                 Child, HGroup, GroupSpacing(0), MUIA_Group_SameSize, TRUE,
  2210.                                     Child, GLOBALPREFS_BTH_ADD        = KeyButton(GetLocaleString(MSG_GLOBALPREFS_ADD_GAD),* GetLocaleString(MSG_GLOBALPREFS_ADD_SC)),
  2211.                                     Child, GLOBALPREFS_BTH_REMOVE    = KeyButton(GetLocaleString(MSG_GLOBALPREFS_REMOVE_GAD),* GetLocaleString(MSG_GLOBALPREFS_REMOVE_SC)),
  2212.                                     Child, GLOBALPREFS_BTH_REMSEL    = KeyButton(GetLocaleString(MSG_GLOBALPREFS_REMSEL_GAD),* GetLocaleString(MSG_GLOBALPREFS_REMSEL_SC)),
  2213.                                     Child, GLOBALPREFS_BTH_SORT        = KeyButton(GetLocaleString(MSG_GLOBALPREFS_SORT_GAD),* GetLocaleString(MSG_GLOBALPREFS_SORT_SC)),
  2214.                                 End,
  2215.                                 Child, HGroup, GroupSpacing(0), MUIA_Group_SameSize, TRUE,
  2216.                                     Child, GLOBALPREFS_BTH_TOP        = KeyButton(GetLocaleString(MSG_GLOBALPREFS_TOP_GAD),* GetLocaleString(MSG_GLOBALPREFS_TOP_SC)),
  2217.                                     Child, GLOBALPREFS_BTH_UP        = KeyButton(GetLocaleString(MSG_GLOBALPREFS_UP_GAD),* GetLocaleString(MSG_GLOBALPREFS_UP_SC)),
  2218.                                     Child, GLOBALPREFS_BTH_DOWN    = KeyButton(GetLocaleString(MSG_GLOBALPREFS_DOWN_GAD),* GetLocaleString(MSG_GLOBALPREFS_DOWN_SC)),
  2219.                                     Child, GLOBALPREFS_BTH_BOTTOM    = KeyButton(GetLocaleString(MSG_GLOBALPREFS_BOTTOM_GAD),* GetLocaleString(MSG_GLOBALPREFS_BOTTOM_SC)),
  2220.                                 End,
  2221.                             End,
  2222.                             Child, VGroup, GroupFrame,
  2223.                                 MUIA_HelpNode, NODE_GPREFS_TOP,
  2224.                                 Child, ColGroup(2),
  2225.                                     Child, TextObject,
  2226.                                         MUIA_HelpNode, NODE_GPREFS_AUTOLOAD,
  2227.                                         MUIA_Text_PreParse, "\33r",
  2228.                                         MUIA_Text_Contents, GetLocaleString(MSG_GLOBALPREFS_AUTOLOAD_GAD),
  2229.                                         MUIA_Weight,  1,
  2230.                                         TextFrame, MUIA_FramePhantomHoriz, TRUE, End,
  2231.                                     Child, HGroup,
  2232.                                         Child, GLOBALPREFS_TXH_AUTOLOAD = TextObject,
  2233.                                             MUIA_HelpNode, NODE_GPREFS_AUTOLOAD,
  2234.                                             MUIA_Weight, 100,
  2235.                                             MUIA_Background   , MUII_TextBack,
  2236.                                             TextFrame, MUIA_Weight, 100,
  2237.                                             MUIA_Text_Contents, initialstring,
  2238.                                         End,
  2239.                                         Child, GLOBALPREFS_BTH_CLEAR = TextObject,
  2240.                                             ButtonFrame,
  2241.                                             MUIA_HelpNode, NODE_GPREFS_CLEAR,
  2242.                                             MUIA_Weight, 0,
  2243.                                             MUIA_Text_Contents, GetLocaleString(MSG_GLOBALPREFS_CLEAR_GAD),
  2244.                                             MUIA_Text_PreParse, "\33c",
  2245.                                             MUIA_Text_SetMax  , FALSE,
  2246.                                             MUIA_Text_HiChar  , * GetLocaleString(MSG_GLOBALPREFS_CLEAR_SC),
  2247.                                             MUIA_ControlChar  , * GetLocaleString(MSG_GLOBALPREFS_CLEAR_SC),
  2248.                                             MUIA_InputMode    , MUIV_InputMode_RelVerify,
  2249.                                             MUIA_Background   , MUII_ButtonBack,
  2250.                                         End,
  2251.                                     End,
  2252.                                     Child, TextObject,
  2253.                                         MUIA_HelpNode, NODE_GPREFS_SHOWPATH,
  2254.                                         MUIA_Text_PreParse, "\33r",
  2255.                                         MUIA_Text_Contents, GetLocaleString(MSG_GLOBALPREFS_SHOWPATH_GAD),
  2256.                                         MUIA_Text_HiChar, *GetLocaleString(MSG_GLOBALPREFS_SHOWPATH_SC),
  2257.                                         MUIA_Weight,  1,
  2258.                                         TextFrame, MUIA_FramePhantomHoriz, TRUE, End,
  2259.                                     Child, HGroup,
  2260.                                         MUIA_HelpNode, NODE_GPREFS_SHOWPATH,
  2261.                                         Child, GLOBALPREFS_CBH_SHOWPATH = KeyCheckMark(TRUE,* GetLocaleString(MSG_GLOBALPREFS_SHOWPATH_SC)),
  2262.                                         Child, HSpace(0),
  2263.                                         Child, HGroup,
  2264.                                             MUIA_HelpNode, NODE_GPREFS_SHOWSIZE,
  2265.                                             Child, TextObject,
  2266.                                                 MUIA_Text_PreParse, "\33r",
  2267.                                                 MUIA_Text_Contents, GetLocaleString(MSG_GLOBALPREFS_SHOWSIZE_GAD),
  2268.                                                 MUIA_Text_HiChar, *GetLocaleString(MSG_GLOBALPREFS_SHOWSIZE_SC),
  2269.                                                 MUIA_Weight,  1,
  2270.                                                 TextFrame, MUIA_FramePhantomHoriz, TRUE, End,
  2271.                                             Child, GLOBALPREFS_CBH_SHOWSIZE = KeyCheckMark(TRUE,* GetLocaleString(MSG_GLOBALPREFS_SHOWSIZE_SC)),
  2272.                                         End,
  2273.                                     End,
  2274.                                 End,
  2275.                             End,
  2276.                         End,
  2277.                     End,
  2278.                     Child, VSpace(2),
  2279.                     Child, HGroup,
  2280.                         MUIA_HelpNode, NODE_GPREFS_TOP,
  2281.                         Child, GLOBALPREFS_BTH_SAVE        =
  2282.                             KeyButton(GetLocaleString(MSG_GLOBALPREFS_SAVE_GAD),* GetLocaleString(MSG_GLOBALPREFS_SAVE_SC)),
  2283.                         Child, HSpace(0),
  2284.                         Child, GLOBALPREFS_BTH_USE =
  2285.                             KeyButton(GetLocaleString(MSG_GLOBALPREFS_USE_GAD),* GetLocaleString(MSG_GLOBALPREFS_USE_SC)),
  2286.                         Child, HSpace(0),
  2287.                         Child, GLOBALPREFS_BTH_LOAD        =
  2288.                             KeyButton(GetLocaleString(MSG_GLOBALPREFS_LOAD_GAD),* GetLocaleString(MSG_GLOBALPREFS_LOAD_SC)),
  2289.                         Child, HSpace(0),
  2290.                         Child, GLOBALPREFS_BTH_CANCEL =
  2291.                             KeyButton(GetLocaleString(MSG_GLOBALPREFS_CANCEL_GAD),* GetLocaleString(MSG_GLOBALPREFS_CANCEL_SC)),
  2292.                     End,
  2293.                 End,
  2294.             End,
  2295.         End;
  2296.  
  2297.     /* --- Preferences Window OK ? -------------------------------------- */
  2298.     if (!WIH_GLOBALPREFS)
  2299.         fail(APH_DFV, "Creating Global Prefs window failed !");
  2300.  
  2301.     /* --- Connetions and Cycle chain ----------------------------------- */
  2302.  
  2303.     DoMethod(WIH_GLOBALPREFS, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  2304.         APH_DFV, 2, MUIM_Application_ReturnID, ID_GLOBALPREFS_CANCEL);
  2305.  
  2306.     DoMethod(GLOBALPREFS_LVH_FILES, MUIM_Notify, MUIA_List_Active,MUIV_EveryTime,
  2307.         APH_DFV, 2, MUIM_Application_ReturnID, ID_GLOBALPREFS_FILES);
  2308.  
  2309.     DoMethod(GLOBALPREFS_LVH_FILES, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE, APH_DFV,
  2310.         2, MUIM_Application_ReturnID, ID_GLOBALPREFS_AUTOLOAD);
  2311.  
  2312.     DoMethod(GLOBALPREFS_BTH_ADD, MUIM_Notify, MUIA_Pressed, FALSE,
  2313.         APH_DFV, 2, MUIM_Application_ReturnID, ID_GLOBALPREFS_ADD);
  2314.     DoMethod(GLOBALPREFS_BTH_REMOVE, MUIM_Notify, MUIA_Pressed, FALSE,
  2315.         APH_DFV, 2, MUIM_Application_ReturnID, ID_GLOBALPREFS_REMOVE);
  2316.     DoMethod(GLOBALPREFS_BTH_REMSEL, MUIM_Notify, MUIA_Pressed, FALSE,
  2317.         APH_DFV, 2, MUIM_Application_ReturnID, ID_GLOBALPREFS_REMSEL);
  2318.     DoMethod(GLOBALPREFS_BTH_SORT, MUIM_Notify, MUIA_Pressed, FALSE,
  2319.         APH_DFV, 2, MUIM_Application_ReturnID, ID_GLOBALPREFS_SORT);
  2320.  
  2321.     DoMethod(GLOBALPREFS_BTH_TOP, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2322.         MUIM_Application_ReturnID, ID_GLOBALPREFS_TOP);
  2323.     DoMethod(GLOBALPREFS_BTH_UP, MUIM_Notify, MUIA_Timer, MUIV_EveryTime, APH_DFV, 2,
  2324.         MUIM_Application_ReturnID, ID_GLOBALPREFS_UP);
  2325.     DoMethod(GLOBALPREFS_BTH_DOWN, MUIM_Notify, MUIA_Timer, MUIV_EveryTime, APH_DFV, 2,
  2326.         MUIM_Application_ReturnID, ID_GLOBALPREFS_DOWN);
  2327.     DoMethod(GLOBALPREFS_BTH_BOTTOM, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2328.         MUIM_Application_ReturnID, ID_GLOBALPREFS_BOTTOM);
  2329.  
  2330.     DoMethod(GLOBALPREFS_BTH_CLEAR, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2331.         MUIM_Application_ReturnID, ID_GLOBALPREFS_CLEAR);
  2332.  
  2333.     DoMethod(GLOBALPREFS_BTH_LOAD, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2334.         MUIM_Application_ReturnID, ID_GLOBALPREFS_LOAD);
  2335.     DoMethod(GLOBALPREFS_BTH_SAVE, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2336.         MUIM_Application_ReturnID, ID_GLOBALPREFS_SAVE);
  2337.  
  2338.     DoMethod(GLOBALPREFS_BTH_USE, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2339.         MUIM_Application_ReturnID, ID_GLOBALPREFS_USE);
  2340.     DoMethod(GLOBALPREFS_BTH_CANCEL, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2341.         MUIM_Application_ReturnID, ID_GLOBALPREFS_CANCEL);
  2342.  
  2343.     DoMethod(WIH_GLOBALPREFS, MUIM_Window_SetCycleChain,
  2344.         GLOBALPREFS_LVH_FILES,
  2345.         GLOBALPREFS_BTH_ADD,
  2346.         GLOBALPREFS_BTH_REMOVE,
  2347.         GLOBALPREFS_BTH_REMSEL,
  2348.         GLOBALPREFS_BTH_SORT,
  2349.         GLOBALPREFS_BTH_TOP,
  2350.         GLOBALPREFS_BTH_UP,
  2351.         GLOBALPREFS_BTH_DOWN,
  2352.         GLOBALPREFS_BTH_BOTTOM,
  2353.         GLOBALPREFS_BTH_CLEAR,
  2354.         GLOBALPREFS_CBH_SHOWPATH,
  2355.         GLOBALPREFS_CBH_SHOWSIZE,
  2356.         GLOBALPREFS_BTH_SAVE,
  2357.         GLOBALPREFS_BTH_USE,
  2358.         GLOBALPREFS_BTH_LOAD,
  2359.         GLOBALPREFS_BTH_CANCEL,
  2360.         NULL);
  2361.  
  2362.     /* --- Set the Checkboxes ------------------------------------------- */
  2363.  
  2364.     setcheckmark(GLOBALPREFS_CBH_SHOWPATH, gp->gp_ShowPath);
  2365.     setcheckmark(GLOBALPREFS_CBH_SHOWSIZE, gp->gp_ShowSize);
  2366.  
  2367.     /* --- Fill the listview -------------------------------------------- */
  2368.     i    = 0;
  2369.     fdp    = &fd;
  2370.  
  2371.     while (*(gp->gp_QuickChange[i].fd_File))
  2372.     {
  2373.         strcpy(fd.fd_Path, gp->gp_QuickChange[i].fd_Path);
  2374.         strcpy(fd.fd_File, gp->gp_QuickChange[i].fd_File);
  2375.  
  2376.         DoMethod(GLOBALPREFS_LVH_FILES,MUIM_List_Insert,&fdp,1,MUIV_List_Insert_Bottom);
  2377.  
  2378.         i++;
  2379.     }
  2380.  
  2381.     /* --- Set main window into sleeping state -------------------------- */
  2382.  
  2383.     set(WIH_MAIN, MUIA_Window_Sleep, TRUE);
  2384.  
  2385.     /* ------------------------------------------------------------------ */
  2386.     /* --- Now open the window ------------------------------------------ */
  2387.     /* ------------------------------------------------------------------ */
  2388.  
  2389.     DoMethod(APH_DFV, OM_ADDMEMBER, WIH_GLOBALPREFS);
  2390.  
  2391.     set(WIH_GLOBALPREFS, MUIA_Window_Open, TRUE);
  2392.  
  2393.     return(TRUE);
  2394. }
  2395.  
  2396. void CloseGlobalPrefs(void)
  2397. {
  2398.     /* --- Close & remove window ---------------------------------------- */
  2399.  
  2400.     set(WIH_GLOBALPREFS, MUIA_Window_Open, FALSE);
  2401.  
  2402.     DoMethod(APH_DFV, OM_REMMEMBER, WIH_GLOBALPREFS);
  2403.  
  2404.     /* --- Now really KILL the subwindow -------------------------------- */
  2405.  
  2406.     MUI_DisposeObject ( WIH_GLOBALPREFS );
  2407.  
  2408.     /* --- Wake up main window ------------------------------------------ */
  2409.  
  2410.     set(WIH_MAIN, MUIA_Window_Sleep, FALSE);
  2411. }
  2412.  
  2413. void dfv_adjust_gauges (void)
  2414. {
  2415.     LONG                    end            = 0L;
  2416.     LONG                    i            = 0L;
  2417.     LONG                    sel            = 0L;
  2418.     LONG                    numsel        = 0L;
  2419.     LONG                    numunsel    = 0L;
  2420.  
  2421.     get(MAIN_LVH_PICS, MUIA_List_Entries, &end);
  2422.  
  2423.     if (end)
  2424.     {
  2425.         for (i=0L ; i<end ; i++)
  2426.         {
  2427.             DoMethod(MAIN_LVH_PICS, MUIM_List_Select, i, MUIV_List_Select_Ask, &sel);
  2428.  
  2429.             if (sel)
  2430.                 numsel++;
  2431.         }
  2432.     }
  2433.     else
  2434.     {
  2435.         numsel = 0L;
  2436.     }
  2437.  
  2438.     numunsel    = end-numsel;
  2439.  
  2440.     set(MAIN_GAH_SELECTED, MUIA_Gauge_Max, end);
  2441.     set(MAIN_GAH_SELECTED, MUIA_Gauge_Current, numsel);
  2442.  
  2443.     set(MAIN_GAH_UNSELECTED, MUIA_Gauge_Max, end);
  2444.     set(MAIN_GAH_UNSELECTED, MUIA_Gauge_Current, numunsel);
  2445. }
  2446.  
  2447. /* ---------------------------------------------------------------------- */
  2448.  
  2449. struct NewMenu menu_list[] =
  2450. {
  2451.     { NM_TITLE,    "",                0,    0,    0,    0                            },
  2452.  
  2453.     { NM_ITEM,    "",                "",    0,    0,    (APTR) ID_MAIN_ABOUT        },
  2454.     { NM_ITEM,    NM_BARLABEL,    0,    0,    0,    0                            },
  2455.     { NM_ITEM,    "",                "",    0,    0,    (APTR) ID_MAIN_PREFS        },
  2456.     { NM_ITEM,    NM_BARLABEL,    0,    0,    0,    0                            },
  2457.     { NM_ITEM,    "",                "",    0,    0,    (APTR) ID_MAIN_QUIT            },
  2458.  
  2459.     { NM_END,    NULL,            0,    0,    0,    0                            },
  2460. };
  2461.  
  2462. /* --- Main loop -------------------------------------------------------- */
  2463.  
  2464. int main(int argc, char *argv[])
  2465. {
  2466.     BOOL        not_end            = TRUE;
  2467.     BOOL        prefs_active    = FALSE;
  2468.     BOOL        str_active        = FALSE;
  2469.     BOOL        no_quickchange    = FALSE;
  2470.  
  2471.  
  2472.     static char        * programname    = "DFV";
  2473.  
  2474.     static char    pattern[64];
  2475.     static char    programpath[256];
  2476.     static char    initialstring[256];
  2477.  
  2478.     char        * LVFormat        = ",";    /* Default for path/file */
  2479.  
  2480.     LONG        i                = 0L;
  2481.  
  2482.     BPTR                tmplock;
  2483.  
  2484.     struct DiskObject    * DFV_DiskObject    = NULL;
  2485.     struct WBStartup    * WBenchMsg            = NULL;
  2486.  
  2487.     static struct GlobalPrefs    GlobalPrefs;
  2488.  
  2489.     struct FileData        * fdp;
  2490.  
  2491.     /* ------------------------------------------------------------------ */
  2492.  
  2493.     init();
  2494.  
  2495.     /* --- Get program path --------------------------------------------- */
  2496.  
  2497.     if (argc)
  2498.     {
  2499.         /* --- Shell startup -------------------------------------------- */
  2500.  
  2501.         GetProgramName(programpath, 256);
  2502.     }
  2503.     else
  2504.     {
  2505.         /* --- Workbench startup ---------------------------------------- */
  2506.         WBenchMsg    = (struct WBStartup *) argv;
  2507.  
  2508.         programname    = WBenchMsg->sm_ArgList->wa_Name;
  2509.  
  2510.         tmplock    = Lock ( programname, ACCESS_READ );
  2511.         NameFromLock ( tmplock, programpath, 256 );
  2512.         UnLock ( tmplock);
  2513.     }
  2514.  
  2515.     /* --- Get real program name ---------------------------------------- */
  2516.  
  2517.     programname = FilePart(programpath);
  2518.  
  2519.     /* --- Try to get disk object --------------------------------------- */
  2520.  
  2521.     DFV_DiskObject = dfv_getdiskobject(programpath);
  2522.  
  2523.     /* --- Try to open locale - if no success, english texts are used! -- */
  2524.  
  2525.     if (LocaleBase = (struct Library *)OpenLibrary("locale.library", 38L))
  2526.     {
  2527.         DFVCatalog        = OpenCatalogA(NULL, "dfview.catalog", NULL);
  2528.     }
  2529.  
  2530.     /* --- Fill the localized strings into the menu structures ---------- */
  2531.  
  2532.     menu_list[0].nm_Label    = GetLocaleString(MSG_MAIN_PROJECT_MENU);
  2533.     menu_list[1].nm_Label    = GetLocaleString(MSG_MAIN_ABOUT_ITEM);
  2534.     menu_list[1].nm_CommKey    = GetLocaleString(MSG_MAIN_ABOUT_ISC);
  2535.     menu_list[3].nm_Label    = GetLocaleString(MSG_MAIN_PREFS_ITEM);
  2536.     menu_list[3].nm_CommKey    = GetLocaleString(MSG_MAIN_PREFS_ISC);
  2537.     menu_list[5].nm_Label    = GetLocaleString(MSG_MAIN_QUIT_ITEM);
  2538.     menu_list[5].nm_CommKey    = GetLocaleString(MSG_MAIN_QUIT_ISC);
  2539.  
  2540.     /* --- Load the global prefs ---------------------------------------- */
  2541.  
  2542.     dfv_readprefs(&GlobalPrefs);
  2543.  
  2544.     /* --- Set global prefs file list ----------------------------------- */
  2545.  
  2546.     i = 0L;
  2547.  
  2548.     while (*(GlobalPrefs.gp_QuickChange[i].fd_File) != 0)
  2549.     {
  2550.         /* --- Use only filenames for cycle gadget ! -------------------- */
  2551.         CYA_QUICK[i]    = GlobalPrefs.gp_QuickChange[i].fd_File;
  2552.         i++;
  2553.     }
  2554.  
  2555.     if(*(GlobalPrefs.gp_QuickChange[0].fd_File) == 0)
  2556.     {
  2557.         i = 0;
  2558.         CYA_QUICK[i++]    = GetLocaleString(MSG_MAIN_QUICK_NOTUSED_TEXT);;
  2559.         /* --- If there is NO text for the cycle gadget besides --------- */
  2560.         /* --- this "not used" thing, make sure that this gadget -------- */
  2561.         /* --- stays disabled ------------------------------------------- */
  2562.  
  2563.         no_quickchange    = TRUE;
  2564.     }
  2565.  
  2566.     /* --- Terminate string vector -------------------------------------- */
  2567.  
  2568.     CYA_QUICK[i]    = NULL;
  2569.  
  2570.  
  2571.     /* --- Now set the listview format string --------------------------- */
  2572.  
  2573.     if(GlobalPrefs.gp_ShowPath)
  2574.     {
  2575.         if(GlobalPrefs.gp_ShowSize)
  2576.         {
  2577.             /* --- Filepath, filename and filesize ---------------------- */
  2578.             LVFormat    = FILELIST_FMT4;
  2579.         }
  2580.         else
  2581.         {
  2582.             /* --- Filepath and filename -------------------------------- */
  2583.             LVFormat    = FILELIST_FMT2;
  2584.         }
  2585.     }
  2586.     else
  2587.     {
  2588.         if(GlobalPrefs.gp_ShowSize)
  2589.         {
  2590.             /* --- Filename and filesize -------------------------------- */
  2591.             LVFormat    = FILELIST_FMT3;
  2592.         }
  2593.         else
  2594.         {
  2595.             /* --- Filename only ---------------------------------------- */
  2596.             LVFormat    = FILELIST_FMT1;
  2597.         }
  2598.     }
  2599.  
  2600.     /* --- Set up the MUI application ----------------------------------- */
  2601.  
  2602.     APH_DFV = ApplicationObject,
  2603.         MUIA_Application_Title,                "DFView",
  2604.         MUIA_Application_Version,            "$VER: DFView " REVISION " " REVDATE + 6,
  2605.         MUIA_Application_Copyright,            "© 1993, " AUTHOR,
  2606.         MUIA_Application_Author,            AUTHOR,
  2607.         MUIA_Application_Description,        GetLocaleString(MSG_APP_DESCRIPTION),
  2608.         MUIA_Application_Base,                "DFVIEW",
  2609.         MUIA_Application_Menu,                menu_list,
  2610.         MUIA_Application_DiskObject,        DFV_DiskObject,
  2611.         MUIA_HelpFile,                        GUIDEFILE,
  2612.  
  2613.         /* --- Set up the main window ----------------------------------- */
  2614.         SubWindow, WIH_MAIN = WindowObject,
  2615.             MUIA_Window_ID, MAKE_ID('M','A','I','N'),
  2616.             MUIA_Window_Title, GetLocaleString(MSG_MAIN_WINDOWTITLE),
  2617.             MUIA_HelpNode, NODE_MAIN_TOP,
  2618.             WindowContents, VGroup,
  2619.                 Child, VGroup,
  2620.                     Child, HGroup, MUIA_Group_SameHeight, TRUE,
  2621.                         Child, VGroup, GroupSpacing(0),
  2622.                             MUIA_HelpNode, NODE_MAIN_FILES,
  2623.                             GroupFrameT(GetLocaleString(MSG_MAIN_PICTURES_GAD)),
  2624.                             Child, MAIN_LVH_PICS = ListviewObject,
  2625.                                 MUIA_Listview_MultiSelect, TRUE,
  2626.                                 MUIA_Listview_DoubleClick, TRUE,
  2627.                                 MUIA_Listview_List, MAIN_LIH_PICS = ListObject,
  2628.                                 InputListFrame,
  2629.                                     MUIA_List_Format, LVFormat,
  2630.                                     MUIA_List_ConstructHook,    & ConstructHook,
  2631.                                     MUIA_List_DestructHook,        & DestructHook,
  2632.                                     MUIA_List_DisplayHook,        & DisplayHook,
  2633.                                     MUIA_List_CompareHook,        & CompareHook,
  2634.                                     End,
  2635.                                 End,
  2636.                             Child, ColGroup(4), GroupSpacing(0), MUIA_Group_SameSize, TRUE,
  2637.                                 Child, MAIN_BTH_ADD        = KeyButton(GetLocaleString(MSG_MAIN_ADD_GAD),*  GetLocaleString(MSG_MAIN_ADD_SC)),
  2638.                                 Child, MAIN_BTH_REMOVE    = KeyButton(GetLocaleString(MSG_MAIN_REMOVE_GAD),* GetLocaleString(MSG_MAIN_REMOVE_SC)),
  2639.                                 Child, MAIN_BTH_REMSEL    = KeyButton(GetLocaleString(MSG_MAIN_REMSEL_GAD),* GetLocaleString(MSG_MAIN_REMSEL_SC)),
  2640.                                 Child, MAIN_BTH_SORT    = KeyButton(GetLocaleString(MSG_MAIN_SORT_GAD),* GetLocaleString(MSG_MAIN_SORT_SC)),
  2641.                                 Child, MAIN_BTH_SELALL    = KeyButton(GetLocaleString(MSG_MAIN_ALL_GAD),* GetLocaleString(MSG_MAIN_ALL_SC)),
  2642.                                 Child, MAIN_BTH_SELSHIFT= KeyButton(GetLocaleString(MSG_MAIN_TOGGLE_GAD),* GetLocaleString(MSG_MAIN_TOGGLE_SC)),
  2643.                                 Child, MAIN_BTH_SELPAT    = KeyButton(GetLocaleString(MSG_MAIN_PATTERN_GAD),* GetLocaleString(MSG_MAIN_PATTERN_SC)),
  2644.                                 Child, MAIN_BTH_SELNONE    = KeyButton(GetLocaleString(MSG_MAIN_NONE_GAD),* GetLocaleString(MSG_MAIN_NONE_SC)),
  2645.                                 Child, MAIN_BTH_TOP        = KeyButton(GetLocaleString(MSG_MAIN_TOP_GAD),* GetLocaleString(MSG_MAIN_TOP_SC)),
  2646.                                 Child, MAIN_BTH_UP        = KeyButton(GetLocaleString(MSG_MAIN_UP_GAD),* GetLocaleString(MSG_MAIN_UP_SC)),
  2647.                                 Child, MAIN_BTH_DOWN    = KeyButton(GetLocaleString(MSG_MAIN_DOWN_GAD),* GetLocaleString(MSG_MAIN_DOWN_SC)),
  2648.                                 Child, MAIN_BTH_BOTTOM    = KeyButton(GetLocaleString(MSG_MAIN_BOTTOM_GAD),* GetLocaleString(MSG_MAIN_BOTTOM_SC)),
  2649.                             End,
  2650.                         End,
  2651.                         Child, VGroup, MUIA_Group_SameWidth, TRUE,
  2652.                             Child, VGroup,
  2653.                             GroupFrameT(GetLocaleString(MSG_MAIN_PICTURELIST_FRAME)),
  2654.                                 MUIA_HelpNode, NODE_MAIN_FILELIST,
  2655.                                 MUIA_Group_SameWidth, TRUE,
  2656.                                 Child, MAIN_BTH_CLEAR    = KeyButton(GetLocaleString(MSG_MAIN_CLEAR_GAD),* GetLocaleString(MSG_MAIN_CLEAR_SC)),
  2657.                                 Child, MAIN_BTH_LOAD    = KeyButton(GetLocaleString(MSG_MAIN_LOAD_GAD),* GetLocaleString(MSG_MAIN_LOAD_SC)),
  2658.                                 Child, MAIN_BTH_SAVE    = KeyButton(GetLocaleString(MSG_MAIN_SAVE_GAD),* GetLocaleString(MSG_MAIN_SAVE_SC)),
  2659.                                 Child, MAIN_BTH_PREFS    = KeyButton(GetLocaleString(MSG_MAIN_FILEPREFS_GAD),* GetLocaleString(MSG_MAIN_FILEPREFS_SC)),
  2660.  
  2661.                                 Child, RectangleObject,
  2662.                                     TextFrame, MUIA_Weight, 0, InnerSpacing(0,0),
  2663.                                 End,
  2664.  
  2665.                                 Child, TextObject,
  2666.                                     MUIA_HelpNode, NODE_MAIN_QUICKCHANGE,
  2667.                                     MUIA_Text_PreParse, "\33c",
  2668.                                     MUIA_Text_Contents, GetLocaleString(MSG_MAIN_QUICK_GAD),
  2669.                                     MUIA_Weight, 0, MUIA_InnerLeft, 0,
  2670.                                     MUIA_InnerRight, 0,
  2671.                                     MUIA_Text_HiChar, * GetLocaleString(MSG_MAIN_QUICK_SC),
  2672.                                 End,
  2673.                                 Child, MAIN_CYH_QUICK = CycleObject,
  2674.                                     MUIA_HelpNode, NODE_MAIN_QUICKCHANGE,
  2675.                                     MUIA_Disabled, no_quickchange,
  2676.                                     MUIA_Cycle_Entries, CYA_QUICK,
  2677.                                     MUIA_ControlChar, * GetLocaleString(MSG_MAIN_QUICK_SC),
  2678.                                 End,
  2679.  
  2680.                                 Child, VSpace(0),
  2681.  
  2682.                                 Child, RectangleObject,
  2683.                                     TextFrame, MUIA_Weight, 0, InnerSpacing(0,0),
  2684.                                 End,
  2685.                                 Child, ColGroup(2),
  2686.                                     MUIA_Group_VertSpacing, 0,
  2687.                                     Child, TextObject,
  2688.                                         MUIA_HelpNode, NODE_MAIN_SELECTED,
  2689.                                         MUIA_Text_PreParse, "\33r",
  2690.                                         MUIA_Weight, 0,
  2691.                                         MUIA_Text_Contents, GetLocaleString(MSG_MAIN_SELECTEDITEMS_GAD),
  2692.                                         TextFrame, MUIA_FramePhantomHoriz, TRUE,
  2693.                                     End,
  2694.                                     Child, MAIN_GAH_SELECTED = GaugeObject,
  2695.                                         GaugeFrame,
  2696.                                         MUIA_HelpNode, NODE_MAIN_SELECTED,
  2697.                                         MUIA_Gauge_Horiz, TRUE,
  2698.                                         MUIA_Weight, 100,
  2699.                                         MUIA_FixHeight, 12,
  2700.                                     End,
  2701.                                     Child, TextObject,
  2702.                                         MUIA_HelpNode, NODE_MAIN_UNSELECTED,
  2703.                                         MUIA_Text_PreParse, "\33r",
  2704.                                         MUIA_Weight, 0,
  2705.                                         MUIA_Text_Contents, GetLocaleString(MSG_MAIN_UNSELECTEDITEMS_GAD),
  2706.                                         TextFrame, MUIA_FramePhantomHoriz, TRUE,
  2707.                                     End,
  2708.                                     Child, MAIN_GAH_UNSELECTED = GaugeObject,
  2709.                                         GaugeFrame,
  2710.                                         MUIA_HelpNode, NODE_MAIN_UNSELECTED,
  2711.                                         MUIA_Gauge_Horiz, TRUE,
  2712.                                         MUIA_Weight, 100,
  2713.                                         MUIA_FixHeight, 12,
  2714.                                     End,
  2715.                                     /* Notice: A VSpace() is CORRECT here   */
  2716.                                     /* because, A VSpace() has a horizontal */
  2717.                                     /* weight of zero!                      */
  2718.                                     Child, VSpace(0),
  2719.                                     Child, ScaleObject, MUIA_Scale_Horiz, TRUE,
  2720.                                     End,
  2721.                                 End,
  2722.                             End,
  2723.                         End,
  2724.                     End,
  2725.                 End,
  2726.  
  2727.                 Child, VSpace(1),
  2728.  
  2729.                 Child, HGroup,
  2730.                     MUIA_HelpNode, NODE_MAIN_PROCESSQUIT,
  2731.                     MUIA_Group_SameSize, TRUE,
  2732.                     Child, MAIN_BTH_SHOW = KeyButton(GetLocaleString(MSG_MAIN_SHOW_GAD),* GetLocaleString(MSG_MAIN_SHOW_SC)),
  2733.                     Child, HSpace(0),
  2734.                     Child, HSpace(0),
  2735.                     Child, HSpace(0),
  2736.                     Child, MAIN_BTH_QUIT = KeyButton(GetLocaleString(MSG_MAIN_QUIT_GAD),* GetLocaleString(MSG_MAIN_QUIT_SC)),
  2737.                     End,
  2738.                 End,
  2739.             End,
  2740.         End;
  2741.  
  2742.     /* --- Everything OK ------------------------------------------------ */
  2743.     if (!APH_DFV)
  2744.         fail(APH_DFV, "Creating application failed !");
  2745.  
  2746.     /* --- Connetions and Cycle chain ----------------------------------- */
  2747.     DoMethod(WIH_MAIN, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  2748.         APH_DFV, 2, MUIM_Application_ReturnID, ID_MAIN_QUIT);
  2749.  
  2750.     DoMethod(MAIN_LVH_PICS, MUIM_Notify, MUIA_Listview_SelectChange, MUIV_EveryTime, APH_DFV,
  2751.         2, MUIM_Application_ReturnID, ID_MAIN_PICS);
  2752.  
  2753.     DoMethod(MAIN_LVH_PICS, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE, APH_DFV,
  2754.         2, MUIM_Application_ReturnID, ID_MAIN_PICVIEW);
  2755.  
  2756.     DoMethod(MAIN_BTH_ADD, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2757.         MUIM_Application_ReturnID, ID_MAIN_ADD);
  2758.     DoMethod(MAIN_BTH_REMOVE, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2759.         MUIM_Application_ReturnID, ID_MAIN_REMOVE);
  2760.     DoMethod(MAIN_BTH_REMSEL, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2761.         MUIM_Application_ReturnID, ID_MAIN_REMSEL);
  2762.     DoMethod(MAIN_BTH_SORT, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2763.         MUIM_Application_ReturnID, ID_MAIN_SORT);
  2764.  
  2765.     DoMethod(MAIN_BTH_SELSHIFT, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2766.         MUIM_Application_ReturnID, ID_MAIN_SELSHIFT);
  2767.     DoMethod(MAIN_BTH_SELALL, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2768.         MUIM_Application_ReturnID, ID_MAIN_SELALL);
  2769.     DoMethod(MAIN_BTH_SELPAT, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2770.         MUIM_Application_ReturnID, ID_MAIN_SELPAT);
  2771.     DoMethod(MAIN_BTH_SELNONE, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2772.         MUIM_Application_ReturnID, ID_MAIN_SELNONE);
  2773.  
  2774.     DoMethod(MAIN_BTH_TOP, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2775.         MUIM_Application_ReturnID, ID_MAIN_TOP);
  2776.  
  2777.     DoMethod(MAIN_BTH_UP, MUIM_Notify, MUIA_Timer, MUIV_EveryTime, APH_DFV, 2,
  2778.         MUIM_Application_ReturnID, ID_MAIN_UP);
  2779.     DoMethod(MAIN_BTH_DOWN, MUIM_Notify, MUIA_Timer, MUIV_EveryTime, APH_DFV, 2,
  2780.         MUIM_Application_ReturnID, ID_MAIN_DOWN);
  2781.  
  2782.     DoMethod(MAIN_BTH_BOTTOM, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2783.         MUIM_Application_ReturnID, ID_MAIN_BOTTOM);
  2784.  
  2785.     DoMethod(MAIN_BTH_CLEAR, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2786.         MUIM_Application_ReturnID, ID_MAIN_CLEAR);
  2787.     DoMethod(MAIN_BTH_SAVE, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2788.         MUIM_Application_ReturnID, ID_MAIN_SAVE);
  2789.     DoMethod(MAIN_BTH_LOAD, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2790.         MUIM_Application_ReturnID, ID_MAIN_LOAD);
  2791.     DoMethod(MAIN_BTH_PREFS, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2792.         MUIM_Application_ReturnID, ID_MAIN_FILEPREFS);
  2793.  
  2794.     /* --- The cycle gadget has to send a notify message ---------------- */
  2795.     /* --- EVERY TIME it is hit ----------------------------------------- */
  2796.     DoMethod(MAIN_CYH_QUICK, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime,
  2797.         APH_DFV, 2, MUIM_Application_ReturnID, ID_MAIN_QUICK);
  2798.  
  2799.     DoMethod(MAIN_BTH_SHOW, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2800.         MUIM_Application_ReturnID, ID_MAIN_SHOW);
  2801.     DoMethod(MAIN_BTH_QUIT, MUIM_Notify, MUIA_Pressed, FALSE, APH_DFV, 2,
  2802.         MUIM_Application_ReturnID, ID_MAIN_QUIT);
  2803.  
  2804.     DoMethod(WIH_MAIN, MUIM_Window_SetCycleChain,
  2805.         MAIN_LVH_PICS,
  2806.         MAIN_BTH_ADD,
  2807.         MAIN_BTH_REMOVE,
  2808.         MAIN_BTH_REMSEL,
  2809.         MAIN_BTH_SORT,
  2810.         MAIN_BTH_SELALL,
  2811.         MAIN_BTH_SELSHIFT,
  2812.         MAIN_BTH_SELPAT,
  2813.         MAIN_BTH_SELNONE,
  2814.         MAIN_BTH_TOP,
  2815.         MAIN_BTH_UP,
  2816.         MAIN_BTH_DOWN,
  2817.         MAIN_BTH_BOTTOM,
  2818.         MAIN_BTH_CLEAR,
  2819.         MAIN_BTH_LOAD,
  2820.         MAIN_BTH_SAVE,
  2821.         MAIN_BTH_PREFS,
  2822.         MAIN_CYH_QUICK,
  2823.         MAIN_BTH_SHOW,
  2824.         MAIN_BTH_QUIT,
  2825.         NULL);
  2826.  
  2827.     /* --- Use prefs ---------------------------------------------------- */
  2828.     /* --- I.e. load initial file --------------------------------------- */
  2829.  
  2830.     if (*(GlobalPrefs.gp_Initial.fd_File))
  2831.     {
  2832.         strcpy(initialstring, GlobalPrefs.gp_Initial.fd_Path);
  2833.         AddPart(initialstring, GlobalPrefs.gp_Initial.fd_File, 256);
  2834.  
  2835.         /* --- Load Filelist -------------------------------------------- */
  2836.         dfv_load_piclist(initialstring);
  2837.     }
  2838.  
  2839.     /* --- Now open the window ------------------------------------------ */
  2840.     set(WIH_MAIN, MUIA_Window_Open, TRUE);
  2841.  
  2842.     /* --- Main loop ---------------------------------------------------- */
  2843.     while (not_end)
  2844.     {
  2845.         LONG signal, id;
  2846.  
  2847.         switch (id = DoMethod(APH_DFV, MUIM_Application_Input, &signal))
  2848.         {
  2849.             case ID_MAIN_ABOUT:
  2850.                     MUI_Request(APH_DFV, WIH_MAIN, 0,
  2851.                     GetLocaleString(MSG_ABOUT_WINDOWTITLE),
  2852.                     GetLocaleString(MSG_ABOUT_OK_GAD),
  2853.                     "\33c\33b%s \33n\n\n \33b%s\33n \33c%s %s \n\33c\33b%s\33n\n\33c%s %s",
  2854.                     GetLocaleString(MSG_ABOUT_BODYTEXT),
  2855.                     "\33c$VER: DFView V" REVISION " (" REVDATE ")\n" + 8,
  2856.                     GetLocaleString(MSG_ABOUT_COPYRIGHT),
  2857.                     AUTHOR " \n",
  2858.                     GetLocaleString(MSG_ABOUT_MUIAPPLICATION),
  2859.                     GetLocaleString(MSG_ABOUT_MUICOPYRIGHT),
  2860.                     "Stefan Stuntz");
  2861.                 break;
  2862.  
  2863.             case ID_MAIN_PREFS:        /* Global Prefs */
  2864.                 OpenGlobalPrefs(&GlobalPrefs);
  2865.                 break;
  2866.  
  2867.             case MUIV_Application_ReturnID_Quit:
  2868.             case ID_MAIN_QUIT:
  2869.                 not_end = FALSE;
  2870.             break;
  2871.  
  2872.             case ID_MAIN_PICS:
  2873.                 dfv_adjust_gauges();
  2874.  
  2875.                 break;
  2876.  
  2877.             case ID_MAIN_PICVIEW:
  2878.                 /* --- Listview got double click ------------------------ */
  2879.                 /* --- Now show the selected item. no matter if it is --- */
  2880.                 /* --- selected or not ---------------------------------- */
  2881.  
  2882.                 dfv_show_active();
  2883.  
  2884.                 break;
  2885.  
  2886.             case ID_MAIN_SHOW:
  2887.  
  2888.                 dfv_show_picture();
  2889.  
  2890.                 break;
  2891.  
  2892.             case ID_MAIN_ADD:
  2893.  
  2894.                 dfv_add_picture();
  2895.  
  2896.                 break;
  2897.  
  2898.             case ID_MAIN_REMOVE:
  2899.                 dfv_rem_picture();
  2900.                 break;
  2901.  
  2902.             case ID_MAIN_REMSEL:
  2903.                 dfv_remsel_picture();
  2904.                 break;
  2905.  
  2906.             case ID_MAIN_UP:
  2907.                 dfv_lv_up(MAIN_LVH_PICS);
  2908.                 break;
  2909.  
  2910.             case ID_MAIN_DOWN:
  2911.                 dfv_lv_down(MAIN_LVH_PICS);
  2912.                 break;
  2913.  
  2914.             case ID_MAIN_TOP:
  2915.                 dfv_lv_top(MAIN_LVH_PICS, sizeof(struct PicData));
  2916.                 break;
  2917.  
  2918.             case ID_MAIN_BOTTOM:
  2919.                 dfv_lv_bottom(MAIN_LVH_PICS, sizeof(struct PicData));
  2920.                 break;
  2921.  
  2922.             case ID_MAIN_SORT:
  2923.                 dfv_lv_sort(MAIN_LVH_PICS);
  2924.                 break;
  2925.  
  2926.             case ID_MAIN_SELALL:
  2927.                 dfv_selall_picture();
  2928.                 break;
  2929.  
  2930.             case ID_MAIN_SELSHIFT:
  2931.                 dfv_selshift_picture();
  2932.                 break;
  2933.  
  2934.             case ID_MAIN_SELPAT:
  2935.                 if (str_active == FALSE)
  2936.                 {
  2937.                     str_active = TRUE;
  2938.                     OpenStringRequester();
  2939.                 }
  2940.  
  2941.                 break;
  2942.  
  2943.             case ID_MAIN_SELNONE:
  2944.                 dfv_selnone_picture();
  2945.                 break;
  2946.  
  2947.             case ID_MAIN_CLEAR:
  2948.                 dfv_clear_piclist();
  2949.                 break;
  2950.  
  2951.             case ID_MAIN_SAVE:
  2952.                 dfv_save_piclist();
  2953.                 break;
  2954.  
  2955.             case ID_MAIN_LOAD:
  2956.                 dfv_load_piclist(NULL);
  2957.                 break;
  2958.  
  2959.             case ID_MAIN_FILEPREFS:
  2960.                 if (prefs_active == FALSE)
  2961.                 {
  2962.                     prefs_active = TRUE;
  2963.                     OpenPrefsWindow();
  2964.                 }
  2965.  
  2966.                 break;
  2967.  
  2968.             case ID_MAIN_QUICK:
  2969.                 dfv_clear_piclist();
  2970.  
  2971.                 strcpy(initialstring, 
  2972.                     GlobalPrefs.gp_QuickChange[GetCycle(MAIN_CYH_QUICK)].fd_Path);
  2973.                 AddPart(initialstring, 
  2974.                     GlobalPrefs.gp_QuickChange[GetCycle(MAIN_CYH_QUICK)].fd_File, 256);
  2975.  
  2976.                 /* --- Load Filelist ---------------------------------------- */
  2977.                 dfv_load_piclist(initialstring);
  2978.  
  2979.                 break;
  2980.  
  2981.             /* --- Global Preferences ----------------------------------- */
  2982.  
  2983.             case ID_GLOBALPREFS_AUTOLOAD:
  2984.                 DoMethod(GLOBALPREFS_LVH_FILES, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &fdp);
  2985.  
  2986.                 strcpy(initialstring, fdp->fd_Path);
  2987.                 AddPart(initialstring, fdp->fd_File, 256);
  2988.  
  2989.                 set(GLOBALPREFS_TXH_AUTOLOAD, MUIA_Text_Contents, initialstring);
  2990.  
  2991.                 break;
  2992.  
  2993.             case ID_GLOBALPREFS_ADD:
  2994.                 dfv_addfileentry();
  2995.                 break;
  2996.  
  2997.             case ID_GLOBALPREFS_REMOVE:
  2998.                 dfv_remfileentry();
  2999.                 break;
  3000.  
  3001.             case ID_GLOBALPREFS_REMSEL:
  3002.                 dfv_remselfileentries();
  3003.                 break;
  3004.  
  3005.             case ID_GLOBALPREFS_SORT:
  3006.                 dfv_lv_sort(GLOBALPREFS_LVH_FILES);
  3007.                 break;
  3008.  
  3009.             case ID_GLOBALPREFS_TOP:
  3010.                 dfv_lv_top(GLOBALPREFS_LVH_FILES, sizeof(struct FileData));
  3011.                 break;
  3012.  
  3013.             case ID_GLOBALPREFS_UP:
  3014.                 dfv_lv_up(GLOBALPREFS_LVH_FILES);
  3015.                 break;
  3016.  
  3017.             case ID_GLOBALPREFS_DOWN:
  3018.                 dfv_lv_down(GLOBALPREFS_LVH_FILES);
  3019.                 break;
  3020.  
  3021.             case ID_GLOBALPREFS_BOTTOM:
  3022.                 dfv_lv_bottom(GLOBALPREFS_LVH_FILES, sizeof(struct FileData));
  3023.                 break;
  3024.  
  3025.             case ID_GLOBALPREFS_CLEAR:
  3026.                 set(GLOBALPREFS_TXH_AUTOLOAD, MUIA_Text_Contents, NULL);
  3027.                 break;
  3028.  
  3029.             case ID_GLOBALPREFS_SAVE:
  3030.                 /* --- First make changes available --------------------- */
  3031.                 dfv_acceptprefs(&GlobalPrefs);
  3032.  
  3033.                 /* --- ...then save them -------------------------------- */
  3034.                 dfv_saveprefs(&GlobalPrefs);
  3035.  
  3036.                 CloseGlobalPrefs();
  3037.                 break;
  3038.  
  3039.             case ID_GLOBALPREFS_USE:
  3040.                 dfv_acceptprefs(&GlobalPrefs);
  3041.  
  3042.                 /* --- NO BREAK HERE ! -------------------------------- */
  3043.  
  3044.             case ID_GLOBALPREFS_CANCEL:
  3045.                 CloseGlobalPrefs();
  3046.                 break;
  3047.  
  3048.             /* ---------------------------------------------------------- */
  3049.  
  3050.             /* --- String requester ------------------------------------- */
  3051.  
  3052.             case ID_SREQ_OK:
  3053.                 stccpy(pattern, GetStr(SREQ_STH_STRING), 64);
  3054.                 dfv_selpat_picture(pattern);
  3055.  
  3056.                 /* --- NO BREAK HERE ! -------------------------------- */
  3057.  
  3058.             case ID_SREQ_CANCEL:
  3059.                 CloseStringRequester();
  3060.                 str_active = FALSE;
  3061.                 break;
  3062.  
  3063.             /* ---------------------------------------------------------- */
  3064.  
  3065.             case ID_FILEPREFS_GETCMD:
  3066.                 dfv_get_command();
  3067.                 break;
  3068.  
  3069.             case ID_FILEPREFS_OK:
  3070.  
  3071.                 /* --- Get values --------------------------------------- */
  3072.                 stccpy(PicPrefs.pp_Command, GetStr(PREFS_STH_CMD), 256);
  3073.                 stccpy(PicPrefs.pp_Params, GetStr(PREFS_STH_PARAMS), 256);
  3074.  
  3075.                 PicPrefs.pp_Pos        = GetBool(PREFS_CBH_POS);
  3076.                 PicPrefs.pp_Auto    = GetBool(PREFS_CBH_AUTO);
  3077.                 PicPrefs.pp_Kind    = GetCycle(PREFS_CYH_KIND);
  3078.  
  3079.                 /* --- NO BREAK HERE ! -------------------------------- */
  3080.  
  3081.             case ID_FILEPREFS_CANCEL:
  3082.  
  3083.                 ClosePrefsWindow();
  3084.                 prefs_active = FALSE;
  3085.                 break;
  3086.  
  3087.             default:
  3088.  
  3089.                 break;
  3090.         }
  3091.  
  3092.         if (not_end && signal)
  3093.             Wait(signal);
  3094.     }
  3095.  
  3096.     dfv_remdiskobject ( DFV_DiskObject );
  3097.  
  3098.     if (DFVCatalog)
  3099.         CloseCatalog(DFVCatalog);
  3100.  
  3101.     if (LocaleBase)
  3102.         CloseLibrary(LocaleBase);
  3103.  
  3104.     fail(APH_DFV, NULL);
  3105. }
  3106.